同じテーブルが2つあります。私はそのような方法でそれらを結合する必要があります:
SELECT f1,f2, xxx
FROM
(SELECT *
FROM tbl1
UNION ALL
SELECT *
FROM tbl2)
ここで、xxxはテーブル名を照会します。ここで、f1フィールドとf2フィールドはから取得されます。出力例:
123 345 'tbl1' -- this rows are from the first table
121 345 'tbl1'
121 345 'tbl1'
123 345 'tbl1'
124 345 'tbl1'
125 345 'tbl2' -- this rows are from the second table
127 345 'tbl2'
前もって感謝します。