473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Nov 15 '07 #1
2 2032
Markus
6,050 Expert 4TB
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:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `branch` WHERE `branch_status` = '1' AND `branch_status` = '2'
  2.  
Right?
Nov 15 '07 #2
mwasif
802 Expert 512MB
Are you looking for this?
Expand|Select|Wrap|Line Numbers
  1. 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
Nov 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: news | last post by:
I'm trying out the Zend Development Environment 4, and for the most part I like it, except for two things. It seems to think certain lines that are perfectly valid are bugs. Like this: while...
2
by: Branko | last post by:
Hello all, I have 2 columns and I search rows with two conditions. SELECT * FROM table WHERE A = '$a' AND B = '$b' How can I make mysql search columns with A condition first and after that...
0
by: JT | last post by:
Hi, I'm sure this isn't a hard one, can someone help? I'm adding a new record to a MySQL database every x seconds. I need to be able to inspect the content of a certain field in this incoming...
4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
11
by: UDBDBA | last post by:
Hi: This is a merge questions which has been posted and answered... in my case need more clairification when target table (tableB) matched multiple rows to be updated based on the ON condition...
2
ak1dnar
by: ak1dnar | last post by:
Please take a look at for this jsp coding. here i can successfully insert the client details to the table. Only after inserting successfully i need to run another query.This will get the userID from...
1
by: damezumari | last post by:
How do I get the total without a condition and the total with the condition at the same time? This is my mysql table: id datetimeconfirmed customerid amount 1 ...
3
by: bnashenas1984 | last post by:
Hi everyone I'v been looking in google but haven't got any answer for my question yet. Actualy I have a search page which works with mysql. my question is: SELECT * FROM usertable WHERE age >...
1
by: cssExp | last post by:
Hi, Assume i have two tables. "accounts" and "accounts_logs" "accounts" (accid, type) "accounts_log" (accid, ip, timestamp) Here i want to choose a radom 3 accids from "accounts" if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.