MySQL Limiting a query to one consistent value

Posted by Lucas Matos on Stack Overflow See other posts from Stack Overflow or by Lucas Matos
Published on 2010-06-14T23:29:44Z Indexed on 2010/06/14 23:32 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

My current query returns a table like:

+------------+
value1 | ....
value1 | ....
value2 | ....
value3 | ....
+------------+

I want:

+------------+
value1 | ....
value1 | ....
+------------+

I want to only receive all rows with the first value. Normally I would do a WHERE clause if I knew that value, and I cannot use a LIMIT because each value has a different number of rows.

Right now My query looks like "SELECT u.*, n.something, w.* FROM ... AS u, ... AS n, ... AS w WHERE u.id = n.id AND w.val = n.val AND u.desc LIKE '%GET REQUEST VARIABLE%';" This works great, except I get way too many rows and using PHP to do this ruins code portability and is superfluous.

Thanks for reading

© Stack Overflow or respective owner

Related posts about php

Related posts about sql