SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  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 gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 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
    rudy.ca | @rudydotca
    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
  •