Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql-将逗号分隔的列表拆分为整数列表_Mysql_Sql - Fatal编程技术网

mysql-将逗号分隔的列表拆分为整数列表

mysql-将逗号分隔的列表拆分为整数列表,mysql,sql,Mysql,Sql,我试图实现的是从help\u ref获取帮助id 到目前为止,iv'e所做的工作: question: +-----------+-------------------------+ |question id| help_ref | +-----------+-------------------------+ | 1 | 1001,1002,1004 | +-----------+------------------------

我试图实现的是从help\u ref获取帮助id

到目前为止,iv'e所做的工作:

question:

+-----------+-------------------------+
|question id|          help_ref       |
+-----------+-------------------------+
|     1     |      1001,1002,1004     |
+-----------+-------------------------+
|     2     |      1005,1002,1001     |
+-----------+-------------------------
help:

+--------------------+
|help_id|  text      |
+--------------------+
| 1001 | sjfdisfidif |
+--------------------+
| 1002 |  dfdjdjdjjd |
+--------------------+
| 1003 | blafdsjdidjd|
+--------------------+
| 1004 | somethibngjd|
+--------------------+
那么,如何将10011002值更改为实际的help\u ref字符串呢

预期结果:

SELECT *
FROM questions AS a
JOIN `help` AS b on find_in_set(b.`help_id`,a.`help_ref`) >0
WHERE b.`help_id` IN (1001,1002) // IM TRYING TO CHANGE THAT TO THE help_ref value
AND `question_id` = 1
我想你想要这个:

SELECT *
FROM questions AS a
JOIN `help` AS b on find_in_set(b.`help_id`,a.`help_ref`) >0
WHERE b.`help_id` IN (a.`help_ref`)
AND `question_id` = 1

help_id | text
1001    | sjfdisfidif
1002    | dfdjdjdjjd
1004    | somethibngjd

你能给我们看看你的预期结果吗?编辑,谢谢@D-Shih
SELECT h.*
FROM help h
INNER JOIN question q
    ON FIND_IN_SET(h.help_id, q.help_ref) > 0 AND q.question_id = 1;