MySQL Forums
Forum List  »  InnoDB

Conditional Limit?
Posted by: Kees van der Sluijs
Date: April 06, 2008 06:17AM

I have need for something like a conditional limit. What I want is to limit the results of the query to the first X elements that satisfy some condition, e.g.:

Select *
FROM Table1
ORDER BY Column1
Limit 10 WHERE Column2="cond2"

So I want to have a result set with X results (possible >10) where exactly 10 results satisfy the given condition. The elements that do not satisfy the condition should be in the result, but should not make the limit stop.

Does anyone have a clue if and how this can be done in mysql?

-edit- I am afraid I posted this in the wrong forum. I actually wanted to post this in the newbie forum. Sorry.



Edited 1 time(s). Last edit at 04/06/2008 06:27AM by Kees van der Sluijs.

Options: ReplyQuote


Subject
Views
Written By
Posted
Conditional Limit?
7461
April 06, 2008 06:17AM
3982
April 06, 2008 06:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.