I have two tables business_details
and business_services
business_details
table have multiple column, but for this query I am using two columns Business_Details_Id
(foreign key for business_services) and Business_Details_Type
. From business_services
I am using a single column Business_Services_Names
which has multiple values that are separated by a comma.
I want to return all Business_Details_Id
after taking input from user which is either a Business_Details_Type
or a Business_Services_Names
(out of multiple values).
I can't use LIKE
to avoid unwanted URLs.FIND_IN_SET returning only one row.
Here is the query i tried:
SELECT business_details.Business_Details_Id
FROM business_details
LEFT JOIN business_services ON
business_details.Business_Details_Id = business_services.Business_Details_Id
WHERE business_details.Business_Details_Active = 1
AND business_details.Business_Details_Type = '$category'
OR FIND_IN_SET('$category', business_services.Business_Services_Names);
Business_Details_Active
is for displaying only those results having value 1
Aucun commentaire:
Enregistrer un commentaire