Mysql query

Hi!Wishing All Happy New Year!

I wanted to ask that I have a common table for clients.If client is given quotation, hes status is 1, if given invoice, hes status is 2 and so on.
If i want to display only the clients who have received the invoice, I fire qury like:

“SELECT existing_clients.exi_workesti_date, existing_clients.exi_work_price, client_master.client_name FROM existing_clients LEFT JOIN client_master
ON existing_clients.client_id=client_master.client_id WHERE MONTH(exi_quo_date) = MONTH(CURDATE()) ORDER BY existing_clients.exi_quo_date ASC”

I have a client master for all my clients.But when I try to display the report of the clients, single client is displayed again and again in all categories and 0 amount and wrong date is displayed. Can anyone tell me how I can display the result only if the data is found in the database related to current status only?And I want to display “NO RECORDS” message is data is not found.
My overall code is:
$query=mysql_query(“SELECT existing_clients.exi_workesti_date, existing_clients.exi_work_price, client_master.client_name FROM existing_clients LEFT JOIN client_master
ON existing_clients.client_id=client_master.client_id WHERE MONTH(exi_quo_date) = MONTH(CURDATE()) ORDER BY existing_clients.exi_quo_date ASC”);
if(mysql_num_rows($query) > 0)
{
while($row=mysql_fetch_array($query))
{
if($row!=0)
{
echo “<tr>
<td class=‘style3’>”; echo $row[‘client_name’]; echo "</td>
</tr>
<tr>
<td class=‘style4’>Rs. "; echo $row[‘exi_work_price’]; echo “</td>
</tr>
<tr>
<td class=‘style4’>”; print date(‘d.m.Y’, strtotime($row[‘exi_workesti_date’])); echo “</td>
</tr>”;
}
}
}
else
{
echo “<tr>
<td class=‘style3’>No Records This Month</td>
</tr>”;
}

where is the status=2 check for received invoice?

you’re “firing” an inadequate query :slight_smile:

what categories? you’re only showing date, price, and name

by the way, your join should be INNER JOIN, not LEFT OUTER JOIN, unless, of course, you have rows in the existing_clients table that have no matching row in the client_master table…

:slight_smile:

Yeh I have added status in WHERE clause.
Now its working well!!
Thx for ur reply :slight_smile: