我有4个表,我想加入一个sql语句。
这些是我的表格:
我已经尝试过这样的声明,但这不起作用
SELECT cm.*, t.*, cd.*, ct.*
FROM exp_members as cm
Inner JOIN transactions as t on (cm.card_id = t.restaurant_id)
Inner JOIN exp_channel_titles as ct on (ct.restaurant_id = t.restaurant_id)
Inner JOIN exp_channel_data as cd on (cd.restaurant_id = ct.restaurant_id)
order by t.created DESC limit 50
答案 0 :(得分:0)
如果你这样做:
SELECT t.*. cd.*, ct.*
FROM transactions as t
LEFT JOIN exp_channel_titles as ct on (t.restaurant_id = ct.restaurant_id)
LEFT JOIN exp_channel_data as cd on (cd.entry_id = ct.entry_id)
WHERE t.cardid > 0
and t.restaurant_id > 0
and ct.status= 'open'
order by t.created DESC limit 50
它给你一些东西??? ...我很抱歉但很难找到没有你的表格结构的简单解决方案:)
Saludos。