i have field in mysql type varchar with field data contains code, and the code is like tree structure with dot (.) as separator between parent and child.
Example 1215 has child 1215.001 and 1215.002
And this is the data each row on database
ID | kode
1 | 1215
2 | 1215.001
3 | 1215.001.001
4 | 1215.002.001
5 | 1215.002
6 | 1215.002.001
How to get the level 2 code?
which its mean will be only the code 1215.001 and 1215.002
Already tried with this query
select * from `kegiatan` where `kode` LIKE '1215.%';
But it get all the code start with 1215 eg: 1215.001.001
Use a regular expression.
This will match everything: