0

ここにこのクエリがあります:

$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

うまくいかず、エラーも何もありませんが、望ましい結果は得られません。

matching.epos_id /rbpos_id は両方とも varchar 型です。なにか提案を?ありがとう

いえ

Matching column
ID  rbpos_id    epos_id
1   123         1234

Rbpos_epos
ID   rbpos_id    epos_id
1    123         1234
2    12          12

行 1 を取得する必要があります...これは、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
4

2 に答える 2

0

1 つの条件に参加して、where 条件でデータをフィルタリングしてみませんか :-

$query_pag_data = "SELECT 
  m.date,
  m.points,
  m.time,
  m.location,
  m.epos_id,
  m.rbpos_id,
  m.time_added,
  r.epos_id,
  r.rbpos_id,
  r.location
  FROM
  matching as m
  LEFT JOIN
  rbpos_epos as r ON m.epos_id = r.epos_id WHERE
  m.rbpos_id = r.rbpos_id AND
  m.user_id = ".$id_user." ORDER BY m.time_added DESC LIMIT ".$start.", ".$per_page;
于 2013-06-18T12:23:35.667 に答える