SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    Nanaimo, BC, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL: Multiple Condition in WHERE clause

    I know I've seen this asked before, but I can't seem to find it. How do I put two different conditions within the WHERE clause in a MySQL query. For example, I tried this:

    SELECT * FROM uicomments WHERE ID=$id AND type=$type

    but I just got an error. Can anybody tell me how to do this properly?

    thanks

  2. #2
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:

    Code:
    SELECT * FROM uicomments WHERE ID='$id' AND type='$type'

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    Nanaimo, BC, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL, I can't believe I left out the quotes.

    It works now, thanks joyce

  4. #4
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    welcome..

  5. #5
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need quotes around numbers, just strings.


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
  •