Results 1 to 2 of 2

Thread: Subquerys

  1. #1
    Join Date
    Apr 2002

    Unanswered: Subquerys


    do you now when subquerys will work in mysql?



  2. #2
    Join Date
    May 2002
    MySQL currently only supports sub selects of the form INSERT ... SELECT ... and REPLACE ... SELECT .... You can however use the function IN() in other contexts.

    In many cases you can rewrite the query without a sub-select:

    SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);

    This can be re-written as:

    SELECT table1.* FROM table1,table2 WHERE;

    The queries:

    SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
    SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where;

    Can be rewritten as:

    SELECT table1.* FROM table1 LEFT JOIN table2 ON where IS NULL

Posting Permissions

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