SQL statement writing

Source: Internet
Author: User
SQL statement syntax $ search1 & quot; SELECTclassroom_id, building_idFROMuse2 & nbsp; WHERE (time {$ time}) & nbsp; AND (building_id {$ building_id }) & nbsql statement writing
$ Search1 = "SELECT classroom_id, building_id FROM use2
WHERE (time = '{$ time }')
AND (building_id = '{$ building_id }')
AND (lesson_id LIKE '$ lesson_id ')";

$ Result1 = mysql_query ($ search1, $ con );

$ Row = mysql_fetch_array ($ result1 );
$ Search2 = "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']}') ";
$ Result2 = mysql_query ($ search2 );


While ($ row = mysql_fetch_array ($ result2 ))
{}

Display mysql_fetch_array () expects parameter 1 to be resource, boolean given in D: \ xampp \ htdocs \ search_free2.php
Use2 stores the usage information of some classrooms, including the time used by each class, the room number, and the building.
Now, we are implementing the function of entering the building number and checking the time for the empty room. First, let's look at the information that I entered. see if there are some room-related information in use2, if there is no relevant implementation, there is no problem.
This is a problem if it is not implemented. I want to find out the classrooms with no relevant information first, and then process the classrooms with relevant information. However, if you are looking for a classroom without relevant information, the above error is displayed. please advise!

------ Solution --------------------
$ Result1 = mysql_query ($ search1, $ con) or die (mysql_error ());
$ Result2 = mysql_query ($ search2) or die (mysql_error ());

Are prompted.

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.