select * from content where
title like '%上海%' or
title like '%北京%' or
title like '%天津%' or
title like '%重庆%'
order by rand() limit 1我在做一个根据地区随机显示广告的功能,
数据可能十万条左右中查询,不知道如果在提高效率,希望指教,谢过
title like '%上海%' or
title like '%北京%' or
title like '%天津%' or
title like '%重庆%'
order by rand() limit 1我在做一个根据地区随机显示广告的功能,
数据可能十万条左右中查询,不知道如果在提高效率,希望指教,谢过
另一种办法是增加一列,从title中提取城市名,然后更新到这一列,建立索引,然后使用'='进行匹配。
select * from (select * from content limit xx,xx)T