Questions about the wording of SQL statements

Source: Internet
Author: User
An issue with SQL statement notation
$search 1 = "Select classroom_id,building_id from Use2
WHERE (time = ' {$time} ')
and (building_id = ' {$building _id} ')
and (lesson_id like ' $lesson _id ') ";

$result 1 = mysql_query ($search 1, $con);

$row = mysql_fetch_array ($result 1);
$search 2 = "SELECT * FROM Classroom2
WHERE (building_id = ' {$building _id} ')
and * not in
(SELECT * from Classroom2
WHERE (building_id = ' {$building _id} ')
and (classroom_id = ' ${row[' classroom_id ']} ') ";
$result 2 = mysql_query ($search 2);


while ($row = Mysql_fetch_array ($result 2))
{}

Show mysql_fetch_array () expects parameter 1 to being resource, boolean given in D:\xampp\htdocs\search_free2.php
Use2 contains information about the use of classrooms, including the time used for each class, the classroom number, which building, etc.
And now the implementation is the input building number, time to find the function of the empty classroom, I first look at the information I entered, see at such a time in the use2 there are no classroom-related information, if all have no relevant implementation no problem.
This is a bit of a problem if there is no implementation. I think if not, I will first find the classrooms without relevant information and then process the classrooms with relevant information. But to find the classroom without relevant information, it shows the error, please advise!

------Solution--------------------
$result 1 = mysql_query ($search 1, $con) or Die (Mysql_error ());
$result 2 = mysql_query ($search 2) or Die (Mysql_error ());

What errors are indicated.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.