Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
jmansa
Forum Commoner
Posts: 81 Joined: Wed Aug 23, 2006 4:00 am
Post
by jmansa » Sun Apr 01, 2007 2:26 pm
I have a table with 8 users ( id= 1 -
and now I want the data for only id 1-4... How do I go about that? Tryid this... but something wrong!
Code: Select all
$result = mysql_query("SELECT * FROM electric2007 WHERE id=1-4 ORDER BY total desc")
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Apr 01, 2007 2:31 pm
Code: Select all
$result = mysql_query("SELECT * FROM electric2007 WHERE id IN (1,2,3,4) ORDER BY total desc")
is probably the simplest way
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Sun Apr 01, 2007 9:21 pm
Just to be picky, but if the id column is the primary key, you can use "id <= 4"... it's a little cleaner to use comparison operators for integer types (probably faster for lookups on larger tables, too).