SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I check multiple conditions when querying a MySQL table?

    Here's a sample of a SQL statement:

    SELECT id1, id2, name FROM table WHERE id='test'

    Is it possible to check id2 as well in one SQL statement? Or do I have to do something like this:

    Code:
    $sql = "SELECT id1, id2, name FROM table WHERE id='test'";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)) {
      if ($row["id2"] == "yes") {
        --- print out what i want here if both conditions met ---
      }
    }
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No its cool to use...


    SELECT id1, id2, name FROM table WHERE id='test' AND id2='yes'

  3. #3
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!


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
  •