【发布时间】:2016-01-24 23:32:40
【问题描述】:
我想要实现的是使用另一个选择中的选择从数据库中获取数据。我成功导入了sender = $id,但是我想返回两个记录:
sender = $id && receiver = any userreceiver = $id && sender = any user
这是我的代码:
$comments = \DB::select('select * from
(select * from comments c
where `sender` = ? //(here)
order by created_at desc) am
group by conversation_id
order by created_at desc
LIMIT 10',
[\Auth::user()->id]);
使用这些会导致错误:
where ? = (sender, receiver)
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sender, receiver)
where ? = (`sender`, `receiver`)
SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1
column(s) (SQL: select * from (select * from comments m
where Test = (`from`, `to`)
【问题讨论】:
标签: mysql sql database laravel