1

我从用户那里得到输入,检查数据库中的值,如果正确,然后做一些操作,比如

    $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 

           }

我可以使用联合运算符吗?

现在我想如果上面的查询失败然后$getuser_key在另一个表中 搜索

我只是想知道是否有可能以这种方式进行,那么如何呢?

4

1 回答 1

2

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'
于 2012-09-18T13:40:55.550 回答