SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast mgsninja's Avatar
    Join Date
    Dec 2001
    Location
    Norway
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multiple id = # with one query possible?

    I'm trying to figure out if I can get some records from a table.
    Lets say I want the records from ID 1,2,4,12,44 and 100.
    Is it possible to get this information in one query?
    I'm trying to have as few query as possible.

    If I can't I have to use
    a query for every ID.
    ...

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Bay Area, California
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SELECT * FROM tablename WHERE id=1 OR id=2 OR id=4 OR id=12 OR id=14 OR id=100

    should work

  3. #3
    SitePoint Enthusiast mgsninja's Avatar
    Join Date
    Dec 2001
    Location
    Norway
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't belive I forgot about "OR". Must be that I've been up for to long

    I'll give you a + for helping me out.
    ...


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
  •