Mysql 使用条件左连接

Mysql 使用条件左连接,mysql,select,join,left-join,Mysql,Select,Join,Left Join,我有这个问题 我需要从匹配表中获取以下字段: date, points 然后,我的匹配表中还有一个epos\u id字段 我有另一个rbpos\u epos表,它有epos\u id和位置字段 我需要使用联接从rbpos\u epos获取位置。。大概是这样的: SELECT matching.date, matching.points, matching.time,matching.location,matching.epos_id,rbpos_epos.epos_id,rbpos_epos.

我有这个问题

我需要从匹配表中获取以下字段:

date, points
然后,我的匹配表中还有一个
epos\u id
字段

我有另一个
rbpos\u epos
表,它有
epos\u id
位置
字段

我需要使用联接从
rbpos\u epos
获取
位置。。大概是这样的:

SELECT matching.date, matching.points, matching.time,matching.location,matching.epos_id,rbpos_epos.epos_id,rbpos_epos.location
FROM matching  WHERE matching.user_id="'.$id_user.'"
LEFT JOIN rbpos_epos where matching.epos_id=rbpos_epos.epos_id; 
在何处使用-

    SELECT matching.date, matching.points, matching.time,matching.location,matching.epos_id,rbpos_epos.epos_id,rbpos_epos.location
   FROM matching LEFT JOIN rbpos_epos ON matching.epos_id=rbpos_epos.epos_id      
      WHERE matching.user_id="'.$id_user.'";
试试这个:

SELECT m.date, m.points, m.time,m.location,m.epos_id,re.epos_id,re.location
FROM matching  m 
LEFT JOIN rbpos_epos re ON m.epos_id=re.epos_id
WHERE m.user_id= 10

这是什么?复制粘贴?有什么问题吗。添加样本表数据检查
位置
字段是否为空。谢谢,您是正确的,我很抱歉造成混淆:)我接受此回答:)
SELECT 
    first_table.date,
    first_table.points,
    first_table.time,
    first_table.location,
    first_table.epos_id,
    rbpos_epos.epos_id,
    rbpos_epos.location
FROM
    first_table
LEFT JOIN
    rbpos_epos ON first_table.epos_id = rbpos_epos.epos_id
WHERE
    first_table.user_id = "'.$id_user.'";