Dils Umesha Dils Umesha - 7 months ago 8
SQL Question

search multiple string in a column.using php and mysql

in my mysql table.there is a column like this.

column_name
apple
ball
cat
daddy
mom


I have two strings (cat and ball for example)
So I need to get records that match cat and ball strings.
I can get one using

SELECT * FROM table_name WHERE column_name='cat'


but how to get two records that match my two strings(I mean
column_name='cat' and column_name='ball'
)
please anyone help me

Answer

I guess you can use 'OR'

 SELECT * FROM table_name WHERE column_name='cat' OR column_name='ball'

For reference http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_where_or