In the DB table, apartments area is stored in the square line according to the following pattern: * "common-living-kitchen". So it looks like 32-28-6 .
Now the question is: how to form a SQL query, if you want to display only the total area of at least the desired value? I understand that the task is not simple, but the database is already filled with ads, and only this functionality will have to be added to the search system without disrupting the work of the rest of the project code.
Up to a point, I used an erroneous request (but this is not an option):
SELECT * FROM apartments WHERE square LIKE '30-%' You can use PHP tools, but here in the request itself, the division into pages through LIMIT is already in progress. Thus, if, after receiving the search results, we select the “necessary” by area of the apartment, then we will have 10 entries on one page, and less on the other page or nothing at all.
Guys, thank you very much for the prompt decision of a difficult question for me! Especially grateful to users of cache and Akina - your solution works successfully!
SELECT * FROM apartments a WHERE (0 + SUBSTRING_INDEX(square, '-' , 1)) >= 30- cache