我在这里有这个查询:
$query_pag_data = "SELECT
matching.date,
matching.points,
matching.time,
matching.location,
matching.epos_id,
matching.rbpos_id,
matching.time_added,
rbpos_epos.epos_id,
rbpos_epos.rbpos_id,
rbpos_epos.location
FROM
matching
LEFT JOIN
rbpos_epos ON matching.epos_id = rbpos_epos.epos_id AND
matching.rbpos_id = rbpos_epos.rbpos_id WHERE
matching.user_id = ".$id_user." ORDER BY matching.time_added DESC LIMIT ".$start.", ".$per_page;
所以,问题是,我在这部分有问题:
rbpos_epos ON matching.epos_id = rbpos_epos.epos_id AND matching.rbpos_id = rbpos_epos.rbpos_id
它不起作用,没有错误或任何东西,但它不会给出预期的结果。
match.epos_id /rbpos_id 都是 varchar 类型。有什么建议吗?谢谢
IE
Matching column
ID rbpos_id epos_id
1 123 1234
Rbpos_epos
ID rbpos_id epos_id
1 123 1234
2 12 12
我应该得到第一行......因为那是matching.rbpos_id和matching.epos_id等于rbpos_epos.rbpos_id和rbpos_epos.epos_id的地方
回声
SELECT matching.date, matching.points, matching.time, matching.location, matching.epos_id, matching.rbpos_id, matching.time_added, rbpos_epos.epos_id, rbpos_epos.rbpos_id, rbpos_epos.location FROM matching LEFT JOIN rbpos_epos ON matching.epos_id = rbpos_epos.epos_id AND matching.rbpos_id = rbpos_epos.rbpos_id WHERE matching.user_id = 4171446415 ORDER BY matching.time_added DESC LIMIT 0, 5