php - How to use where condition for the for a selected column using subquery? -
i have 2 columns company , product.
i use following query products matching particular string...
select id,(select name company product.cid=company.id) company,name,selling_price,mrp product name '$qry_string%'
but when need list products of specific company how can do?
i tried following in vein
select id,(select name company product.cid=company.id) company,name,selling_price,mrp product company '$qry_string%'
help me
what trying not require subquery, simple join enough. try this:
select c.name, p.id, p.name, p.selling_price, p.mrp company c inner join product p on c.id = p.cid c.name '$qry_string%'
i think problem query tried cannot use fields result of subquery (in case, "company") in where
clause. might try having
instead.
Comments
Post a Comment