Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with a simple SQL statement

Status
Not open for further replies.

MyTool

Programmer
Oct 18, 2009
1
US
I know this sounds retarded.

But I want to find a way I can single out the higest rating quote on my website through an SQL statement.

For the life of me I can't think of a way to get the higest rating singled out from the rest.

$sql = 'SELECT * FROM `quotes` ORDER BY `id` where `rating` This is where I get stuck ';

What on earth would you put here?

Help please

 
Code:
SELECT * 
  FROM quotes 
 WHERE rating =
       ( SELECT MAX(rating)
           FROM quotes )
in ANSI SQL, the backticks will give a syntax error

next time, you might wish to try forum436 :)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top