The database contains strings of type

"2,2,1,2" "1,2,3,1" "2,2,3,5" 

How to get rows that start with the lines "2.2".

    1 answer 1

    I have a feeling that your database structure is somehow not quite properly organized. But if you still have to do this sample, then probably so:

     SELECT * FROM `table_name` WHERE `field_name` LIKE '2,2%' 

    PS If the field you have is FULLTEXT, then you can still try:

     SELECT * FROM `table_name` WHERE MATCH (`field_name`) AGAINST ('2,2*' IN BOOLEAN MODE) 
    • Yet it is not organized. Just parameters can be any number, not 4. - linya
    • one
      @linya, I'm talking about this. Maybe it makes sense to store the parameters not as a string, but separately in another table? - Deonis
    • Honestly, I have little idea how it should look. This series is absolutely ordered, but how many digits he has is not known. And it seems to me more costly to collect them from another table. How will be faster? If there is an exemplary literature on this issue, I will be grateful. - linya 2:46 pm
    • one
      Since you did not describe the task in detail, you have to play “guess the melody”. I can assume and describe in an abstract example: There is a table of products and a table of color solutions for the product. If you have a “trumpeted” product and you will keep the “red” color identifier in the next field, and then search for it as you were going to, then this will certainly be very expensive and I do not recommend doing it this way. - Deonis