Reply
Old 08-03-2005, 02:42 PM SQL Query
Average Talker

Posts: 23
I am trying to get the biggest number then pull all the related information based on that number out of the database, here is the code of using:

select d.*, (select max(d2.sale) from data d2) as big from data d where d.sale=big

However tells me does not know what big is, any sugguestions?
tobeyt23 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-03-2005, 07:25 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Are you using MySQL? Does MySQL support sub-queries in this fashion?

EDIT: Ok, I see now that MySQL does not support sub-queries (cool to know) since v 4.1. Have you run the query in PHPmyAdmin? It gives great errors that contribute to your ability to isolate the problem.
__________________
—Kyrnt

Last edited by Kyrnt : 08-03-2005 at 07:32 PM.
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-03-2005, 07:29 PM
asm
Extreme Talker

Posts: 217
Location: UK.Lancashire(true)
I wondered that myself but I can find no reference to using SQL variables with MySQL
asm is offline
Reply With Quote
View Public Profile Visit asm's homepage!
 
Old 08-03-2005, 07:35 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Your select syntax is weird, try this:

Code:
 select @max := MAX(sale) from data;
followed by:
Code:
 select * from data where sale = @max;
Should work from version 3.23.6 of MySQL upwards
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)

Last edited by 0beron : 08-03-2005 at 07:38 PM.
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to SQL Query
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13539 seconds with 12 queries