LIMIT by row field

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

LIMIT by row field

Post by someberry »

I have a table which says how many rows to pull out the database. However, instead of having to do a query to get the row limit and then perform the actual query, I would like to combine the query. However, I don't think MySQL allows for this. Example of what I would like to do is below:

Code: Select all

SELECT a.field,
FROM `a_table` a, `b_table` b
WHERE b.table_id = a.table_id
LIMIT b.limit
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: LIMIT by row field

Post by John Cartwright »

Unfortunately, mysql only allows for constants in the LIMIT clause.
Post Reply