SELECT product FROM Table_name_1
WHERE id = '% textbox1.text %'
UNION
SELECT product FROM Table_name_2
WHERE id = '% textbox1.text %'
UNION
SELECT product FROM Table_name_3
WHERE id = '% textbox1.text %'
通过此代码,我可以获得产品。但是我怎么知道这个结果从哪个表中取出?所以我也想知道表名。
答案 0 :(得分:0)
您还可以选择常量值并为其指定列名称。
SELECT product, 'Table_name_1' as table FROM Table_name_1 WHERE id = '% textbox1.text %'
UNION
SELECT product, 'Table_name_2' as table FROM Table_name_2 WHERE id = '% textbox1.text %'
UNION
SELECT product, 'Table_name_3' as table FROM Table_name_3 WHERE id = '% textbox1.text %'