Reputation: 667
I have a query like this :
$sql = "
SELECT
*
FROM
tbl_emp_data
WHERE
company_qualification = '$q'
";
Now my company_qualification
field is not a single value ,instead its a words separated by commas like BSc,BA,BCom
etc . And the value $q
is a single value say BA
. So how can I search the company data from the value $q
. I can not use LIKE
since its going to match fields like BA
and BBA
.
Upvotes: 0
Views: 127
Reputation: 14863
$sql = "
SELECT
*
FROM
tbl_emp_data
WHERE
company_qualification IN ('".implode("','",$q)."')
";
Upvotes: 1
Reputation: 10646
You can use IN
like this:
SELECT * FROM tbl_emp_data WHERE company_qualification IN ('BSc', 'BA', 'BCom');
Upvotes: 0
Reputation: 86346
You can use FIND_IN_SET
$sql = "
SELECT
*
FROM
tbl_emp_data
WHERE
FIND_IN_SET($q,company_qualification)
";
Upvotes: 4