or的2句SQL的ike如何按like的先后排列数据

WBOY
Release: 2016-06-13 12:48:43
Original
753 people have browsed it

or的2句SQL的ike怎么按like的先后排列数据?
name LIKE "%A%" OR time LIKE "%b%"

怎么排完like A的结果 在排 B的结果?


------解决方案--------------------
 ...order by if(instr(name,'A') >0,1,0) desc
------解决方案--------------------
这个半句足够可以理解了
就是说按查找含有'A'的字符串转成0,1,然后根据01排序,含有的就是1,没有含有的就0
最后的排序就是order by if(instr(name,'A') >0,1,0) desc 
------解决方案--------------------
一样的,用上面的那个语句一样的,结合一下啊,这都不明白么?
order by if(instr(name,'A') >0,1,(if(instr(name,'b') >0,1,(if(instr(name,'e') >0,1,0)))) desc  
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!