Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
確かに簡単な質問ですが、MySQL クエリを修正できません: 準備されたクエリの下で実行したい
select id from table1 where c_id = :c_id union select id,name from table2 where c_id = :c_id and temp = :temp
したがって、各テーブル選択の出力には異なる数の列があります。これが機能しない理由ですか?
SELECT次のように、最初のクエリでリテラル値を使用できます。
SELECT
SELECT id, 'no name' AS "name" FROM table1 WHERE c_id = :c_id UNION ALL SELECT id, name FROM table2 WHERE c_id = :c_id AND temp = :temp;