我有这样的桌子
tableUser:
id | name
-----+------------
1 | John Smith
2 | Maria
3 | peter
tableComplaint
id | ComplaintIssue | User
-----+------------------+-----
1 | Isssue1 | 1
2 | Issue nth | 3
3 | Issue infinity | 4
现在我正试图从下面的查询中获取输出
select
tc.id, tc.complaintissue, tu.name tc
from
tablecomplaint tc
join
tbuser tu on tu.id = tc.user
where
tc.comlaintissue like '%%' or tu.name like '%%'
但是我无法在tu.name
上放置类似运算符。
我希望我的输出查询也允许使用用户名搜索。
答案 0 :(得分:2)
您两次出现“ tc”
select tc.id, tc.complaintissue, tu.name [->]tc from tablecomplaint [->] tc
join tbuser tu on tu.id = tc.user
where tc.comlaintissue like '%%' or tu.name like '%%'
你想表达什么意思?
select tc.id, tc.complaintissue, tu.name from tablecomplaint tc
join tbuser tu on tu.id = tc.user
where tc.comlaintissue like '%%' or tu.name like '%%'
答案 1 :(得分:0)
有效,
select
tc.id, tc.complaintissue, tu.name tc
from
tablecomplaint tc
join
tbuser tu on tu.id = tc.user
where
tc.complaintissue like '%%' or tu.name like '%%'