This question already has answers here:
how to select record whose matching percentage is higher than other using like operator in sql server?
(3个答案)
5年前关闭。
我想从我的分类数据库中搜索一些数据,假设我要搜索泰姬陵酒店,那么泰姬陵酒店应该位于顶部。但是根据我使用的查询,所有的酒店都被检索到,而泰姬陵酒店位于下一页或其他位置。
我的查询是:
请建议我一些可行的方法
(3个答案)
5年前关闭。
我想从我的分类数据库中搜索一些数据,假设我要搜索泰姬陵酒店,那么泰姬陵酒店应该位于顶部。但是根据我使用的查询,所有的酒店都被检索到,而泰姬陵酒店位于下一页或其他位置。
我的查询是:
SELECT *
FROM tbl_user_products
WHERE (company_name='$a')
OR (product_name='$a')
OR ( company_name like '%$a%'
OR category like '%$a%'
OR subcategory like '%$a%'
OR title like '%$a%'
OR description like '%$a%'
OR website like '%$a%'
OR product_name like '%$a%')
AND (city='$cityselect')
LIMIT $startResults, $resultsPerPage
请建议我一些可行的方法
最佳答案
尝试
order by FIELD(field_name,'taj') ;
关于php - SQL查询搜索,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21926303/