Jump to content

Can wildcards be used in WHERE statements?


Jim R

Recommended Posts

Wildcards can be used using LIKE.

 

SELECT username, email FROM users WHERE email LIKE '%@gmail.com';

The % is the wildcard here.

 

http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html

http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

The underscore is a single character wildcard.  If you want it literally you must escape it.

 

but I'm wondering if I can extract values that only have an underscore in the field of data.

 

That would just be an underscore by itself.  Do you mean entries with underscores anywhere in the field?  In this case:

 

'%\_%'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.