-1
I have a query in PHP + Mysql:
SELECT * From tb WHERE campo1='valor' or campo2='valor' or campo3='valor'
I would like the query to return to me in which of the fields was found the value.
-1
I have a query in PHP + Mysql:
SELECT * From tb WHERE campo1='valor' or campo2='valor' or campo3='valor'
I would like the query to return to me in which of the fields was found the value.
1
Use CASE / WHEN:
SELECT *, CASE WHEN campo1='valor' THEN 'campo1' WHEN campo2='valor' THEN 'campo2' ELSE 'campo3' END AS campo
FROM tb
WHERE campo1='valor' or campo2='valor' or campo3='valor'
It worked, thank you
Browser other questions tagged php mysql
You are not signed in. Login or sign up in order to post.
Welcome to the SO-pt, please read the manual on how NOT to ask questions, especially the section Do not provide a Minimum, Complete and Verifiable code
– Pedro Sanção