Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Thanked 5 Times in 5 Posts

    How to get data using single select query

    I'm created two table first one is test1 and second one is test2.
    In first table one field is id and in second table one field is id.
    in first table two data/value insert 1 and 2 and second table four data/value insert 1, 2, 3 and 4

    I want to access only 3 and 4 data with use join key

    Is this possible to get data using single select query.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,746 Times in 4,708 Posts
    SELECT table2.*
    FROM table2 LEFT JOIN table1 ON table2.id = table1.id
    WHERE table1.id IS NULL
    But you might find it easier to think of if you do it this way:
    SELECT * 
    FROM table2
    WHERE id NOT IN ( SELECT id FROM table1 )
    The two queries really do the same thing.


    Posting Permissions

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