SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: How do I use multiple "WHERE" clause?

  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do I use multiple "WHERE" clause?

    Hi there, I'm trying out something like as follows


    $query_Recordset1 = sprintf("SELECT mark WHERE class=A AS mark1, mark WHERE class=B AS mark2, mark WHERE class=C AS mark3
    FROM biology WHERE `year` = '%s'", $colname_Recordset1);
    $Recordset1 = mysql_query($query_Recordset1, $arundel) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

    ?>

    Is there not a simpler way of achieving this?

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,461
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    yes

    the first step to simplicity is...

    ... to pull out the mysql query, discard all the php code, and test your query directly in the mysql engine



    please show us what that does first, before we simplify it further
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

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
  •