整个查询:
SELECT NULL,
ELT( MOD( A.contact_id, (SELECT count(*) FROM `ak_contact` WHERE `contact_type_id` = 12) )+1, (SELECT CONCAT( "'",GROUP_CONCAT(CAST(contact_id AS CHAR(7)) SEPARATOR "','"),"'" ) FROM `ak_contact` WHERE `contact_type_id` = 12) ) as operator_id,
B.account_id, A.contact_id, A.email
FROM ak_contact A
JOIN ak_accounts B USING (contact_id)
GROUP BY A.email, A.contact_id, B.account_id
ORDER BY A.contact_id DESC
子查询应为每一行一一选择 ID 号 10493、10495、11262、11800、12362、13405 之一:
ELT( MOD( A.contact_id, (SELECT count(*) FROM `ak_contact` WHERE `contact_type_id` = 12) )+1, (SELECT CONCAT( "'",GROUP_CONCAT(CAST(contact_id AS CHAR(7)) SEPARATOR "','"),"'" )
#result: ELT(MOD(3333, 5)+1, '10493','10495','11262','11800','12362','13405')
问题是我不能强迫 ELT(A.contact_id, subquery) 与子查询一起工作。或者我怎么能做这样的事情:
ELT(MOD(3333, 5)+1, '10493','10495','11262','11800','12362','13405')
在主查询内部