MySQL Forums
Forum List  »  Newbie

Re: How to pass varchar as WHERE field IN param
Posted by: Jassm Rahma
Date: August 05, 2016 05:22PM

this is my stored procedure and it param_country is a varchar, comma separated, e.g.

BH
BH, US, IN
JP, SA, BH, FR


SELECT locations.location_id, companies.company_name, locations.location_name, first_payroll, last_payroll
FROM locations
JOIN country ON country.country_code_alpha2 = locations.country_code
JOIN companies ON companies.company_id = locations.company_id
LEFT JOIN payroll ON payroll.location_id = locations.location_id
WHERE locations.country_code IN (param_country) AND payroll_active = TRUE
GROUP BY locations.location_id
ORDER BY companies.company_name;

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.