Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.