私は、可変長のWHERE
引数を受け入れることができる1つのクエリに統合したい3つのクエリを持っています。私は私の人生のためにこれをする方法を思い出すことができません。可変パラメータを使用した単純なクエリ
PreparedStatement queryOne = connection.prepareStatement
("SELECT columnOne, columnTwo, columnThree FROM tableOne WHERE columnOne = ?;");
PreparedStatement queryTwo = connection.prepareStatement
("SELECT columnOne, columnTwo, columnThree FROM tableOne WHERE columnTwo = ?;");
PreparedStatement queryThree = connection.prepareStatement
("SELECT columnOne, columnTwo, columnThree FROM tableOne WHERE columnOne = ? AND columnTwo = ?;");
「統合する」とはどういう意味ですか?結果の結合、結果の交差などを返すクエリが必要ですか? –
私は、可変長のWHERE文を受け入れる単一のPreparedStatementを作成したいと考えています。 –
はい、「統合」を意味する場合は、UNIONが役立つかもしれません。 –