Jump to content

Recommended Posts

I'm not sure why this query is not working on MySql 5.0.24 as it works on MySql 4.1.14.  I am trying to create a simple subquery as:

 

SELECT a.login_id

FROM disco_vendor_ids a

WHERE a.vendor = 'XYZ'

AND a.effdt = (SELECT max(b.effdt)

FROM disco_vendor_ids b

WHERE a.vend_id = b.vend_id)

 

When I try to run this query in 5.0.24 I keep getting:

#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 max(b.effdt)

FROM disco_vendor_ids b

WHERE a.vend_id ...

 

I don't think it's a syntax error as the query runs in 4.1.14.  I have only recently set this database up in 5.0.24 perhaps there is a setting somewhere that is not correct?  Any help would be greatly appreciated.

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/62583-select-max-subquery/
Share on other sites

clearstatcache - The table structure is:

 

Table name: disco_vendor_ids

 

Field      Type

-------    -----

vend_id  int(5)

effdt      date

vendor    varchar(15)

descr      varchar(35)

login_id    varchar(30)

passwd    varchar(30)

 

 

I think there might be difference between MySql 4.1.14 and 5.0.24 and the way queries are parsed?  I'm not sure what "features" were added for 5.0.24, but the subquery worked in 4.1.14.  Thanks for your help so far.

Link to comment
https://forums.phpfreaks.com/topic/62583-select-max-subquery/#findComment-311743
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.