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 in different versions of php mysql Client API

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-05, 06:43
yebot yebot is offline
Registered User
 
Join Date: Aug 2005
Posts: 4
Syntax in different versions of php mysql Client API

So I run this qry via phpmyadmin with php mysql Client API v. 3.23.49.

Code:
SELECT
`shownum`, `showdate`, `showdesc`, `venue`, `city`, `state`
FROM `table1`
WHERE `showdate`
NOT IN
(SELECT DISTINCT(`date`) FROM `table2`)
This works fine until I run the same qry on an identical database on my host's server with php mysql Client API v. 4.0.25. MySQL throws the following error:

#1064 - 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 `date` FROM `table2 ` ) LIMIT 0, 30' at line

Is my syntax really incorrect or do the different versions dislike my 'nested' SELECT statement?

Last edited by yebot; 11-28-05 at 06:50.
Reply With Quote
  #2 (permalink)  
Old 11-28-05, 09:27
felixg felixg is offline
Registered User
 
Join Date: Apr 2005
Location: Lier, Belgium
Posts: 122
Quote:
Originally Posted by yebot
Is my syntax really incorrect or do the different versions dislike my 'nested' SELECT statement?
'Nested' SELECT statements are supported from MySQL 4.1 onwards.

--
felix
Reply With Quote
  #3 (permalink)  
Old 11-28-05, 10:00
yebot yebot is offline
Registered User
 
Join Date: Aug 2005
Posts: 4
Thanks Felix.


I have Table1 where each record has a 'showdate'. Then in table2, there will be a series of records that have a 'date' that should correspond to a date in the Table1 'showdate'.

I want to run a qry that will show me all records in Table1 where Table1.showdate does not have at least one match in Table2.date.

Since my host is using MySQL 4.0.25, how can I accomplish this without using a 'nested' SELECT?
Reply With Quote
  #4 (permalink)  
Old 11-28-05, 10:06
felixg felixg is offline
Registered User
 
Join Date: Apr 2005
Location: Lier, Belgium
Posts: 122
Quote:
Originally Posted by yebot
I want to run a qry that will show me all records in Table1 where Table1.showdate does not have at least one match in Table2.date.
Code:
SELECT
  Table1.*
FROM Table1
LEFT JOIN Table2 ON Table2.date = Table1.showdate
WHERE
  Table2.date IS NULL
--
felix
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