Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Free text search

Status
Not open for further replies.

ashz

Programmer
Dec 9, 2002
43
ES
How can I run a SQL statement that will search for a text (e.g. "omni") in the entire field and in all the records?
 
Im not sure I understood you correctly, but this will work for a search in a one column in one table.

SELECT * FROM table_name WHERE column_name like '%omni%'

If your using a string from a html form text field the $_GET variabel you have for that value can just be inserted into the search string, ie:

...like '%$variable%'
 
Thanks.

But How to search in all the columns in one table.
 
Code:
SELECT * FROM <table> WHERE <column_1> LIKE '%<string>%' OR <column_2> LIKE '%<string>%'
And so on... //Daniel
 
Is there a shorter way since I have a lot of columns
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top