Professional Web Applications Themes

Can this basic query be simplified? - MySQL

SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9' OR userID='27' OR userID='92' ORDER BY rand() LIMIT 30...

  1. #1

    Default Can this basic query be simplified?

    SELECT * FROM table WHERE userID='1' OR userID='5' OR userID='9' OR
    userID='27' OR userID='92' ORDER BY rand() LIMIT 30

    Ciaran Guest

  2. #2

    Default Re: Can this basic query be simplified?

    On 12 Mar, 10:47, "Ciaran" <com> wrote: 

    SELECT
    *
    FROM `table`
    WHERE userID IN ('1', '5', '9', '27', '92')
    ORDER BY rand()
    LIMIT 30

    Captain Guest

  3. #3

    Default Re: Can this basic query be simplified?

    Brilliant! That's much better, thanks a lot!
    Ciarán

    Ciaran Guest

  4. #4

    Default Re: Can this basic query be simplified?

    Captain Paralytic wrote:
     
    >
    > SELECT
    > *
    > FROM `table`
    > WHERE userID IN ('1', '5', '9', '27', '92')
    > ORDER BY rand()
    > LIMIT 30[/ref]


    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
    Brian Guest

  5. #5

    Default Re: Can this basic query be simplified?

    Ciaran <com> wrote:
     

    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
    Rik Guest

  6. #6

    Default Re: Can this basic query be simplified?

    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
    Rik Guest

Similar Threads

  1. basic query question
    By Mike in forum MySQL
    Replies: 6
    Last Post: May 9th, 05:22 PM
  2. Basic query speed question
    By cobramichelle in forum Coldfusion Database Access
    Replies: 1
    Last Post: December 23rd, 05:48 PM
  3. Replies: 2
    Last Post: November 18th, 12:14 PM
  4. Simplified Field Notation Calculation
    By Robert_Heise@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 2
    Last Post: June 3rd, 09:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139