Is it possible to find out which column was matched against on a multiple LIKE query?
e.g:
SELECT * FROM table WHERE col_a LIKE = '%B' OR col_b LIKE = '%A'
if(MATCHED COL_A){
do this;
}else{
do that;
}
Is it possible to find out which column was matched against on a multiple LIKE query?
e.g:
SELECT * FROM table WHERE col_a LIKE = '%B' OR col_b LIKE = '%A'
if(MATCHED COL_A){
do this;
}else{
do that;
}
You can simply put your conditions in select statement and name it with new alias which will have a boolean value 0/1 for matching columns,Also =
after like doesn't make any sense
SELECT *,
col_a LIKE '%B' AS match_cola,
col_b LIKE '%A' AS match_colb
FROM table WHERE col_a LIKE '%B' OR col_b LIKE '%A'
Fetching result from query you can check it as
$result = fetch result from query;
//loop
if($result['match_cola'] == 1){
echo 'col_a matched';
}
//end loop