Atif Azad Atif Azad - 2 years ago 114
MySQL Question

Subquery Syntax error for sql

Hi i am trying to fetch data from two tables(

) in PHP and MySQL.

table there is a column
which have four different values. The thing I want to do is to display
values in four different column for each product something like below:

S.No Product Name Status Val1 Status Val2 Status Val2 Status Val4

I am using below using below query

SELECT i.product_id, i.status, COUNT( * ) AS count FROM issues i
INNER JOIN products p ON i.product_id =
GROUP BY `product_id`

Answer Source

Thank you guys, i have solved it

(select count(*) from issues where status=val1 AND as Status Val1,
(select count(*) from issues where status=val2 AND as Status Val2,
(select count(*) from issues where status=val3 AND as Status Val3,
(select count(*) from issues where status=val4 AND as Status Val4
FROM issues i INNER JOIN products p 
ON i.product_id = 
where p.branch_id = 1
GROUP BY product_id
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download