SELECT Date, Time FROM MD WHERE MD.Date = ? OR MD.Time = ?
UNION ALL
SELECT Date, Time FROM Fuji WHERE Fuji.Date = ? OR Fuji.Time = ?;
``` `?` 成为你的搜索价值。列计数必须相同,但列的顺序必须相同。
如果列计数不匹配,修复方法是用null填充缺少的值,如:
SELECT Date, Time, column3 FROM MD WHERE MD.Date = ? OR MD.Time = ? UNION ALL SELECT Date, Time, null as column3 FROM Fuji WHERE Fuji.Date = ? OR Fuji.Time = ?;
甚至可以在这两个表中填充空值,如:
SELECT null as column0, Date, Time, column3 FROM MD WHERE MD.Date = ? OR MD.Time = ? UNION ALL SELECT column0, Date, Time, null as column3 FROM Fuji WHERE Fuji.Date = ? OR Fuji.Time = ?;
1条答案
按热度按时间sqougxex1#
你要找的是工会。您可以选择:
SELECT Date, Time, column3 FROM MD WHERE MD.Date = ? OR MD.Time = ?
UNION ALL
SELECT Date, Time, null as column3 FROM Fuji WHERE Fuji.Date = ? OR Fuji.Time = ?;
SELECT null as column0, Date, Time, column3 FROM MD WHERE MD.Date = ? OR MD.Time = ?
UNION ALL
SELECT column0, Date, Time, null as column3 FROM Fuji WHERE Fuji.Date = ? OR Fuji.Time = ?;