网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 204.45.15.210
Old 2015-12-19, 11:33 PM
Wills Point Wills Point is offline
初级会员
 
Join Date: 2010-03-12
Posts: 1
Wills Point 现在声名狼藉
Default MySql的like语句中的通配符:百分号、下划线和escape

MySql的like语句中的通配符:百分号、下划线和escape

%代表任意多个字符

Sql代码

select * from user where username like '%huxiao';

select * from user where username like 'huxiao%';

select * from user where username like '%huxiao%';

_代表一个字符

Sql代码

select * from user where username like '_';

select * from user where username like 'huxia_';

select * from user where username like 'h_xiao';

如果我就真的要查%或者_,怎么办呢?使用escape,转义字符后面的%或_就不作为通配符了,注意前面没有转义字符的%和_仍然起通配符作用

Sql代码

select username from gg_user where username like '%xiao/_%' escape '/';



select username from gg_user where username like '%xiao/%%' escape '/';
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 07:42 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.