www.webdeveloper.com
Results 1 to 5 of 5

Thread: PHP n MySQL help..

  1. #1
    Join Date
    Oct 2005
    Location
    Winthrop
    Posts
    45

    Unhappy PHP n MySQL help..

    hi guys...
    i need a bit of help in mysql using php..

    i wanted to display any of the result of the 1st query that did not match the result of the 2nd query only..

    so for example, if the result of query 1 is 14, 15, 16, 17, 18..
    and the result of query 2 is 15,16..
    i wanted to display only 14,17,18...

    any suggestions on how i should do the queries?

    hope the explanation is quite helpful..
    any help and suggestions will be very appreciated..
    thank you guys..

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    so if the column you're returning is "id" then..

    query 1 where id not in query 2.

  3. #3
    Join Date
    Oct 2005
    Location
    Winthrop
    Posts
    45
    ehm.. yeah.. but the thing is,
    how do you do the "not in" query 2 thing?
    i mean the proper php/mysql code..
    thx chazzy..

  4. #4
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    it is literally "ID NOT IN"

    so
    select id from table where id not in (select id from other_table)

    no php required.

  5. #5
    Join Date
    Oct 2005
    Location
    Winthrop
    Posts
    45
    ah! kewl chazzy.. thanks alot..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles