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.
我在两张不同的桌子上做一个 UNION ALL。查询效果很好,但我需要设置一个名为tab1 或 2 的额外列来告诉哪个表。
tab
示例查询:
SELECT * FROM news UNION ALL SELECT * FROM highlight
在我的 php 代码中,我会做 $row['tab']==1 然后它的新闻..
SELECT *, 1 AS `tab` FROM news UNION ALL SELECT *, 2 AS `tab` FROM highlight