简体   繁体   中英

mysql find_in_set matching 2 columns

I have a query working find_in_set working like this

$groupid = 245;
$formsidlist = '52,57,103,104,105,107,109,110';
$query = "SELECT * FROM #__immi_visaformfields WHERE 
FIND_IN_SET('$groupid','field_duplicate')  AND published='1' AND 
 FIND_IN_SET(formid,'$formsidlist') ORDER BY id";

Now I have formsidlist changed to

$formsidlist = '52-1,57-2,103-1,104-1,105-2,107-1,109-1,110-1';

and from 52-1, 52 should be compared to formid column and 1 should be compared to formversionid column.

How do I acheive this?

将formid与'-'和formversionid连接:

FIND_IN_SET(concat(formid, '-', formversionid), '$formsidlist') ORDER BY id";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM