...

View Full Version : select all from a database and find position of a certain entry



tomharto
08-24-2011, 02:58 AM
I need to list everything from a database order by a certain field, which i can do, however i almost need to find the position of a entry (WHERE `userID` = '$userID') that would be the criteria, how would i do that? I can do a full DB search and a WHERE criteria search but i can figure out how to do a mix of both.

EDIT: This would be done in PHP if that makes any difference.

Old Pedant
08-24-2011, 03:19 AM
Ummm...



SELECT list, of, fields
FROM tablename
WHERE somecondition
ORDER BY somefield

The parts of a SELECT must be given in that order.

There are other parts that can be used, of course:


SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
LIMIT

when used, they must be used in that order. (And there are even other much more rarely used parts that have to be in a particular order...and then there are joins and unions and subselects...but the above are the basic parts.)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum