Fungsi INSTR di MySQL

Fungsi INSTR di MySQL


mysql> select * from aa;

+---------+---------+
|   id    |  angka  |
+---------+---------+
|       1 | 2,3,5,4 |
|       4 | 4       |
|       2 | 2       |
|       3 | 2,6     |
+---------+---------+
4 rows in set (0.00 sec)


mysql> select * from aa where INSTR(CONCAT(',', angka,','), ',2,');
+---------+---------+
|   id    |  angka  |
+---------+---------+
|       1 | 2,3,5,4 |
|       2 | 2       |
|       3 | 2,6     |
+---------+---------+
3 rows in set (0.00 sec)


mysql> select * from aa where INSTR( angka, '4');
+---------+---------+
|   id    |  angka  |
+---------+---------+
|       1 | 2,3,5,4 |
|       4 | 4       |
+---------+---------+
2 rows in set (0.00 sec)