Results 1 to 5 of 5

Thread: syntax error

  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Angry Unanswered: syntax error

    i'm trying to execute the folloowing query

    SELECT StoreName, ARIAnetID, ID
    FROM store_info
    WHERE ID
    NOT IN (SELECT ID FROM received_stores WHERE Date BETWEEN '2003-09-12 00:00:00' AND '2003-09-12 23:59:59')

    but i keep on getting

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT ID
    FROM received_stores
    WHERE Date
    BETWEEN '2003-09-12

    if i separate the 2 queries they execute ok but together they don't. looked through all the examples and i could find and i couldn't see anything obvious i was doing wrong. help?

    TIA

  2. #2
    Join Date
    Jul 2003
    Posts
    35
    hi,

    seems an obvious question, but... what version of mysql are you using?

    chrs,
    ash

  3. #3
    Join Date
    Sep 2003
    Posts
    2
    sorry, 4.0.14-nt

  4. #4
    Join Date
    Jul 2003
    Posts
    35
    subselects are only available from version 4.1+

  5. #5
    Join Date
    Sep 2003
    Location
    London
    Posts
    56
    This should do what you're after:

    Code:
    SELECT
      info.StoreName,
      info.ARIAnetID,
      info.ID
    FROM
      store_info AS info
    LEFT JOIN
      received_stores AS received
        ON
          info.ID = received.ID
    WHERE
      received.Date BETWEEN '2003-09-12 00:00:00' AND '2003-09-12 23:59:59'
        AND
          received.ID IN NOT NULL
    Regards,
    Matt.

Posting Permissions

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