0
+---------+----------+-----------
|   id    |   value  |  map_id  |
+---------+----------+-----------
|    1    |   avcne  |   1,2,3  |
+---------+----------+-----------
|    2    |   fdhsj  |   5,6,7  |
+---------+----------+-----------
|    3    |   kqrno  |   8,9,0  |
+---------+----------+-----------

FROm the table above

SELECT value FROM table_above where map_id = 2

Then the result would be 'avcne'.

SELECT values FROM table_above where map_id = 6

Then the result would be 'fdhsj'.

Is there any better way to do this without using %-% such as

SELECT value FROM table_above where map_id = %2%

Thanks in advance.

Note: this is just for a temporary table.

iyal
  • 1,175
  • 1
  • 8
  • 22

1 Answers1

0

MySQL's find_in_set is just what you're looking for:

SELECT value FROM table_above WHERE FIND_IN_SET(2, map_id)
Mureinik
  • 297,002
  • 52
  • 306
  • 350