If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > syntax error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-03, 21:45
amorphis amorphis is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Angry 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
Reply With Quote
  #2 (permalink)  
Old 09-13-03, 00:17
asherh asherh is offline
Registered User
 
Join Date: Jul 2003
Posts: 34
hi,

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

chrs,
ash
Reply With Quote
  #3 (permalink)  
Old 09-13-03, 23:29
amorphis amorphis is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
sorry, 4.0.14-nt
Reply With Quote
  #4 (permalink)  
Old 09-14-03, 00:13
asherh asherh is offline
Registered User
 
Join Date: Jul 2003
Posts: 34
subselects are only available from version 4.1+
Reply With Quote
  #5 (permalink)  
Old 09-14-03, 05:06
Mincer Mincer is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On