我正在使用此代码:
SELECT *
FROM admins, vips
WHERE admins.Expired < CURDATE() + INTERVAL 3 DAY
AND vips.Expired < CURDATE() + INTERVAL 3 DAY
我先是2行,后面是2行。但我只在“vips”表中获得了2行。为什么呢?
答案 0 :(得分:0)
尝试为两个表指定*
,如下所示:
SELECT admins.*, vips.*
FROM admins, vips
WHERE admins.Expired < CURDATE() + INTERVAL 3 DAY
AND vips.Expired < CURDATE() + INTERVAL 3 DAY
编辑:上面的答案没有帮助,你需要一个UNION SELECT
:
SELECT *
FROM (SELECT * FROM vips
UNION
SELECT * FROM admins) derivedTable -- this is an alias of the subquery
WHERE Expired < CURDATE() + INTERVAL 3 DAY