• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

MySQL Select Like

December 27, 2020

Here’s how to perform SQL searches using the like operator.

# Format
SELECT column1, column2 FROM table_name WHERE column LIKE pattern;
# Search for an entry starting with a 'joe.'
SELECT id,username,address FROM users WHERE username LIKE 'joe%';
# Search for an entry ending with a 'joe.' 
SELECT id,username,address FROM users WHERE username LIKE '%joe';
# Search for any entry with 'joe' from any position. 
SELECT id,username,address FROM users WHERE username LIKE '%joe%';
# Finally, using "_" as wildcards. Find any field with "j" in the second position.
SELECT id,username,address FROM users WHERE username LIKE '_j';

# Format SELECT column1, column2 FROM table_name WHERE column LIKE pattern; # Search for an entry starting with a 'joe.' SELECT id,username,address FROM users WHERE username LIKE 'joe%'; # Search for an entry ending with a 'joe.' SELECT id,username,address FROM users WHERE username LIKE '%joe'; # Search for any entry with 'joe' from any position. SELECT id,username,address FROM users WHERE username LIKE '%joe%'; # Finally, using "_" as wildcards. Find any field with "j" in the second position. SELECT id,username,address FROM users WHERE username LIKE '_j';

Filed Under: Linux, Misc Tagged With: like, mysql, pattern, search

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023