0

I have 2 tables

question:

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

help:

+--------------------+
|  id  |  text       |
+--------------------+
| 1001 | sjfdisfidif |
+--------------------+
| 1002 |  dfdjdjdjjd |
+--------------------+
| 1003 | blafdsjdidjd|
+--------------------+
| 1004 | somethibngjd|
+--------------------+

basically I want to join the data from the help table by using the help_ref column. thank you

Erik17
  • 33
  • 4
  • What's the expected result for this sample data? – Mureinik Jun 23 '18 at 21:15
  • 2
    If possible...normalize your data.... otherwise every query will be an uphill battle – Ctznkane525 Jun 23 '18 at 21:17
  • MySQL provides `FIND_IN_SET` for unnormalized data (comma separated values) i never tryed a join with `FIND_IN_SET` as on statements. Maybe this works `SELECT ... question JOIN help ON FIND_IN_SET(help.id, question.help_ref)` .. Keep in mind that if it works it never can use a index to speeds up the performance. – Raymond Nijland Jun 23 '18 at 21:24
  • it works but im getting the value of the first one only – Erik17 Jun 23 '18 at 22:15

0 Answers0