Database query to search using address

前端 未结 2 1353
滥情空心
滥情空心 2021-01-26 06:01

I am developing a search functionality to search for dealers by their address(i.e. by postcode(zip) or by name or by city)for my project. user will be provided with only one htm

2条回答
  •  庸人自扰
    2021-01-26 06:13

    In MySQL you do it like this:

         "SELECT `zip`, `name`, `city` FROM `dealers` WHERE `zip` = '$zip' ORDER BY `zip` DESC"
         "SELECT `zip`, `name`, `city` FROM `dealers` WHERE `name` = '$name' ORDER BY `name`"
         "SELECT `zip`, `name`, `city` FROM `dealers` WHERE `city` = '$city' ORDER BY `city`"
    

    I don't use Oracle but I think that it is the same. (This code assumes that zip is a varchar, if it is an integer value just remove the ' ')

提交回复
热议问题