Superior Web Solutions - Web Development 905 532 9642Free Project Estimator
HOME CLIENTS SERVICES BLOG ABOUT US CONTACT US
Categories:
 Internet Marketing
 iPhone iPad Apps Development
 IT Humour
 IT Industry News
 Search Engines
 User Guides
 Web Development
Browse by tags
Search Blog:
RSS
Subscribe to our newsletter
Name*:
E-Mail*:
Recent Posts
On April 21st 2013 SWS will be celebrating its 11th birthday!
mysql_query deprecated as of PHP 5.5.0
Web Development on Subdomains on Godaddy Servers ( $_SERVER[`DOCUMENT_ROOT`] Issue)
Usage of Canadian Coat of Arms in Web Design
MySQL COUNT(*) VS PHP mysql_num_rows
Convert String to Lowercase or Uppercase Tool (+ PHP code)
August 09, 2012 - MySQL: Get The Position Of The Record In The Table

Problem: there is a table in SQL database and we need to get a position of the row ordered by one of the fields, read more for the solution.

Solution: There is no SQL statement that will give you the position, but you can find how many records are above, and adding 1 to this will give you the position:

SELECT COUNT(*)
FROM tableName
WHERE fieldToOrderBy >
(
                SELECT fieldToOrderBy
                FROM tableName
                WHERE PK = 123
)

Associated tags:  SQL, MySQL, SELECT
Add Comment:
Name*:
E-Mail: Website:
Your message*:
»
© 2000 - 2013 Superior Web Solutions