Hello, in general there are many, many posts, each post has t.location and t.id_city , the full address is written in the location for example: "Russia, Yekaterinburg, Pushkin st., 7", So, you need to pull out of the database data on the city, how best to do it:

 SELECT * FROM post t WHERE t.id_city = :id_city 

or

 SELECT * FROM post t WHERE t.location LIKE %:location% //:location => 'Екатеринбург' 

I will be very happy if you give a better option

  • 3
    Of course it is better to search by id_city. - Opalosolo
  • o'k, thanks. - bemulima
  • one
    Search by location is best only if for some reason the index is only on location - cadmy

1 answer 1

Reply from comments

Of course, the search will be much faster than the id_city numeric field. It is probably better to search for the second option only if, for some reason, the index is only in the location field.