【发布时间】:2015-10-29 07:33:58
【问题描述】:
我有来自这个链接SQL: Select like column from two tables的开发问题
表1中的A列:
a
b
c
表2中的A列:
d
e
f
结果集应该是:
a
b
c
d
e
f
然后在该表中有投诉 ID,我想按投诉 ID 过滤,但在 where 子句中出错。 这是我的 sql 看起来很像
SELECT firstName, message, date
FROM replyComplaintUsers rcu
JOIN users u ON rcu.userId = u.userId
UNION
SELECT firstName, message, date
FROM replyComplaintControls rcc
JOIN controls c ON rcc.controlId = c.controlId
WHERE rcu.complaintId = $complaintId and rcc.complaintId = $complaintId
ORDER BY date DESC
谁能告诉我怎么了?
当我使用这个 sql 时我得到这个值 “where 子句”中的未知列“rcu.complaintId” 谢谢
【问题讨论】:
-
WHERE 子句仅适用于第二个 SELECT。
-
您的 select 子句中的 claimId 字段在哪里...
标签: sql