0
$sql = "SELECT m.*,p.place_title
                FROM members_meetings mm,meetings m,places p
                WHERE mm.meeting_id=m.meeting_id AND mm.member_id=$member_id AND m.cat_id=$cat_id AND m.place_id=p.place_id AND m.meeting_status<>0
                ORDER BY mm.meeting_id DESC";

我有另一个表 meeting_time_poll 包含这些列:

poll_id
meeting_id
poll_closed
poll_dates
poll_times

我需要 poll_id where meeting_time_poll.meeting_id=meeting.meeting_id 我怎样才能把它放在 sql 中?

注意:并非所有会议表中的 meeting_id 在 meeting_time 轮询中都有对应

4

1 回答 1

0

这个怎么样?

$sql = "SELECT m.*,p.place_title, mp.poll_id
            FROM 
                members_meetings mm,
                meetings m,places p, 
                meeting_time_poll mp
            WHERE 
                mm.meeting_id=m.meeting_id
                AND mm.member_id=$member_id 
                AND m.cat_id=$cat_id 
                AND m.place_id=p.place_id 
                AND m.meeting_status<>0 
                AND mp.meeting_id=m.meeting_id
            ORDER BY mm.meeting_id DESC";

另外我建议使用JOIN.

于 2012-06-25T08:38:40.433 回答