我从用户那里得到一个输入,检查数据库中的值,如果正确的话,然后执行如下操作

    $getuser_key = $_POST['keyy'];

    $sql = "SELECT *  from demo_participant WHERE meeting_id_id IN(SELECT id FROM demo_meeting WHERE meetingID = '$get_meetingid') and `key` = '$get_meetinkey'";
    mysql_real_escape_string($sql);
    $result = mysql_query($sql) or die (mysql_error());
    while ($row = mysql_fetch_array($result)) {

          somthing

           }

我可以用联合接线员吗?
现在我想如果上面的查询get失败,那么在另一个表中搜索
我只想知道,这是有可能的,如果是这样,那怎么办?

最佳答案

JOIN他们:

 SELECT *
 from demo_participant dp
 INNER JOIN demo_meeting dm ON dp.meetingID = dm.meetingID
        AND dm.Key = '$get_meetinkey'
 INNER JOIN demo_thirdTable dt ON -- Somecondition here
 WHERE dp.key = '$get_meetinkey'

10-07 21:49