Jump to content

Taking 2 Statements Into 1


tomtimms

Recommended Posts

I have 2 queries that I would like to somehow condense into one as I don't want to make 2 calls to my database.

 

My 2 queries are.

 

$sql = "SELECT company FROM revenue_company WHERE status = '1'"; 

$sql2 = "SELECT company FROM revenue_company WHERE status = '2'"; 

 

and I just want to get the number of rows returned for each query so I have

$row = mysql_num_rows($result);

$row2 = mysql_num_rows($result2);

 

There has to be an easier way for me to condence my query into 1 and get the amount of rows returned that either have a status of 1 or a status of 2.  Any suggestions would be great.

 

Link to comment
https://forums.phpfreaks.com/topic/201436-taking-2-statements-into-1/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.