473,775 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple where condition in PHP Mysql

3 New Member
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 2042
Markus
6,050 Recognized Expert Expert
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 Recognized Expert Contributor
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
3022
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 ($row_pass = mysql_fetch_array($result_pass)) { It gives an "Assignment in Condition" error whenever it encounters a line like that, which is a lot. It gives a little explanation box
2
20068
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 within these condition B. I would like to know, how mysql search works.
0
2270
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 record and, when a condition is met, send an email. I suppose I could have some script inspect the latest record every x seconds and use sendmail, but I'm unfamiliar with scripting daemons on
4
16758
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 customers; I can execute each statement individually but get the 'you have an error in
11
2558
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 for a single row from source table (tableA). There is a one to many relationship from source to target table (because of the ON condition). We also know upfront that thsi merge will result in all update and no inserts. The source table is tableA...
2
9179
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 the table.(Auto_Increment value). But i failed to build up a condition to check the insertion, how to do it. <%@ page language="java" import="java.sql.*" %> <% String driver = "org.gjt.mm.mysql.Driver";...
1
1554
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 2007-08-14 06:19:03 1 12.25 2 2007-08-06 06:19:19 1 15 3 2007-08-02 06:19:41 2 5 4 2007-08-07 06:19:58 2 7.25
3
3975
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 > 10 OR age < 5 AND name = 'myname'> I mean I need the table to return rows with the 3rd condition ( name='myname' ) and one of the other conditions ( age>10 ) or ( age<5 ) Thanks
1
2559
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 available, but each of them should be compared with "accounts_log". Lests say a one of the accid chose is A1, then take users IP and current time - time(). now compare A1 exists in "accounts_log" with the ip, this can exist multiple times but pick one...
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10268
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10048
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.