This is a discussion on Can this basic query be simplified? within the MySQL Database forums, part of the Database Forums category; SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9' OR userID='27' OR userID='92' ORDER BY ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On 12 Mar, 10:47, "Ciaran" <cronok...@hotmail.com> wrote:
> SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9' OR > userID='27' OR userID='92' ORDER BY rand() LIMIT 30 SELECT * FROM `table` WHERE userID IN ('1', '5', '9', '27', '92') ORDER BY rand() LIMIT 30 |
|
|||
|
Captain Paralytic wrote:
> On 12 Mar, 10:47, "Ciaran" <cronok...@hotmail.com> wrote: >> SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9' OR >> userID='27' OR userID='92' ORDER BY rand() LIMIT 30 > > SELECT > * > FROM `table` > WHERE userID IN ('1', '5', '9', '27', '92') > ORDER BY rand() > LIMIT 30 You can simplify that even further by removing the '' around the numbers, they are not needed. -- Brian Wakem Email: http://homepage.ntlworld.com/b.wakem/myemail.png |
|
|||
|
Ciaran <cronoklee@hotmail.com> wrote:
> SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9'OR > userID='27' OR userID='92' ORDER BY rand() LIMIT 30 SELECT * FROM table WHERE userID IN (1,5,9,27,92) ORDER BY RAND() LIMIT 30 -- Rik Wasmus Posted on Usenet, not any forum you might see this in. Ask Smart Questions: http://tinyurl.com/anel |
|
|||
|
D'OH!
Didn't see it was already ansered.. -- Rik Wasmus Posted on Usenet, not any forum you might see this in. Ask Smart Questions: http://tinyurl.com/anel |