Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 23
Trades: 0
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
 
 
Register now for full access!
Old 08-03-2005, 08:25 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
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 08:32 PM..
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-03-2005, 08:29 PM
asm
Extreme Talker

Posts: 217
Location: UK.Lancashire(true)
Trades: 0
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, 08:35 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
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';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 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.51148 seconds with 12 queries