我需要加入两个表,我已经有了第一个表的代码:
$query = "SELECT * FROM civicrm_event";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['title_en_US']. " - ". $row['id'];
echo "<br />";
我需要加入另一个名为civicrm_participant
的地方,我需要提取contact_id
选择此表的条款是:
civicrm_event.id = civicrm_participant.event_id
然后我需要回复[title_en_US]
[id]
[contact_id]
帮助...
答案 0 :(得分:1)
You should read joins in mysql
做这样的事情:
$query = "SELECT ce.title_en_US, ce.id, cp.event_id FROM civicrm_event AS ce JOIN civicrm_participant AS cp ON ce.id=cp.event_id";