Multiple where condition in PHP Mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atanu4833
    New Member
    • Nov 2007
    • 3

    #1

    Multiple where condition in PHP Mysql

    Hello,

    I want to retrieve record from mysql database for a php web page with two or more where condition i.e

    select * from branch where branch_status=' 1'

    select * from branch whre branch_status=' 2'

    (I need Total no of branches, status 1 br. and status 2 br. in the same row)

    so that I can have the following table
    --------------------------------------------------------------------------------------------------------------
    Total No. Branch | No of Br with status1 | No of Br with status=2
    --------------------------------------------------------------------------------------------------------------


    Pleae help me.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by atanu4833
    Hello,

    I want to retrieve record from mysql database for a php web page with two or more where condition i.e

    select * from branch where branch_status=' 1'

    select * from branch whre branch_status=' 2'

    (I need Total no of branches, status 1 br. and status 2 br. in the same row)

    so that I can have the following table
    --------------------------------------------------------------------------------------------------------------
    Total No. Branch | No of Br with status1 | No of Br with status=2
    --------------------------------------------------------------------------------------------------------------


    Pleae help me.
    I'm not totally sure what you're asking for, but i believe you might be talking about:

    [code=mysql]
    SELECT * FROM `branch` WHERE `branch_status` = '1' AND `branch_status` = '2'
    [/code]
    Right?

    Comment

    • mwasif
      Recognized Expert Contributor
      • Jul 2006
      • 802

      #3
      Are you looking for this?
      [CODE=mysql]SELECT COUNT(*) AS "Total Branches", (SELECT COUNT(*) FROM branch WHERE branch_status=' 1') AS "Status 1 branches", (SELECT COUNT(*) FROM branch WHERE branch_status=' 2') AS "Status 2 branches" FROM branch[/CODE]

      Comment

      Working...