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!

math expression in the LIMIT clause?

Status
Not open for further replies.

Dfly

Technical User
Oct 2, 2002
13
US
SELECT code, name, thumbnail, image
FROM inventory
WHERE (category_id = 6)
ORDER BY name
LIMIT ((2-1)*15) , 3

I need this query statement to have the math calculation in the LIMIT clause to adjust for the page links.

((current_page_link-1)*maxrows/pg)

It keeps getting tossed out because of the (brackets) surrounding the numbers. Is there any way to do it?

Dfly
 
You would have to do your calculations in your scripting language and use integers.
 
The parenthesis stall out in the LIMIT clause, but are accepted in other areas of a query. I can do my calculations for the LIMIT start_pos, 3 in an auxiliary query.

SELECT (((2-1)*15)+3) AS start_pos;


I was hoping that I had something misplaced and could do it all in one query. Thank you both for your response.

Dfly


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top