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.
SQL クエリで 3 つの一意のテーブルから列を取得していたとします。そして、それらの列のデータ型が同じであるとします。特定の行がどのテーブルから来たかを示す余分な列を結果に含める方法はありますか? table_A の場合は 1、table_B の場合は 2 など。
SELECT "table1" which, colX the_col FROM table1 WHERE ... UNION SELECT "table2" which, colY the_col FROM table2 WHERE ... ...