selecting rows that contain pattern as a subset

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

selecting rows that contain pattern as a subset

Post by jaymoore_299 »

I have a table with only one column with values like
row1 = a123 , row2 = 231 , row3 = 1233 , row4 = 123

how would I select all rows that contain "123" so that rows 1 , 3 , 4 would be a match?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

look up LIKE syntax:

Code: Select all

SELECT * FROM `table` WHERE `field` LIKE '%123%'
Post Reply