-1

我有 4 个表要加入到一个 sql 语句中。

这些是我的表:

  1. exp_members : card_id (pk)
  2. 交易:card_id(pk), restaurant_id(pk)
  3. exp_channel_data : restaurant_id(pk)
  4. exp_channel_titles : restaurant_id(pk)

我已经尝试过这样的声明,但这不起作用

    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
4

1 回答 1

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

它给了你一些东西???.....对不起,如果没有你的表格结构,很难找到一个简单的解决方案:)

萨卢多斯。

于 2013-02-25T14:01:56.600 回答