Page 1 of 1

How do I search a table for all rows containing a phrase?

Posted: Mon May 05, 2008 2:45 am
by mirra1515
I am trying to figure out what mysql command would be necessary to search a table and return all rows that have a certain phrase in a column.

For instance, if my table was set up like this:

Database: test_db
Table: test_table
Columns: ID int(4), dataName varchar(255), dataContents text

How would I query the database so that it returns all rows in which "dataContents" contains a phrase such as "ipsum epsum". The phrase could be anywhere within the text field. For example:

"Indige huetoro ipsum epsum floro dolore"

Can I use LIKE? Or is there even a way to do this with mysql commands? Any suggestions would be greatly appreciated. Thank you :)

Re: How do I search a table for all rows containing a phrase?

Posted: Mon May 05, 2008 3:21 am
by Christopher
SELECT * FROM test_table WHERE dataContents LIKE "%ipsum epsum%"