これを回避するためには、副問い合わせに別名を付与する必要がある。
sakila のデータを利用して検証する。
容易に UNION 結合を実現するために、同じテーブルに対して違う条件で抽出したものを結合する。
select * from country where country like 'N%' union select * from country where country like '%N'この問合せに対して SELECT すると、エラーが発生する。 副問い合わせに別名を付与すると、問題なく抽出される。
select * from ( select * from country where country like 'N%' union select * from country where country like '%N') N
0 件のコメント:
コメントを投稿