Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Searching text with SQL

Name: Anonymous 2008-07-02 17:18

Database with various text fields. When user searches the site wish to check 3 of those fields for the matching search term [name, filename, comment]. Basic level just needs to return any rows that match the search term in any of the 3 fields. The fields are all short no more than 256 characters.

What would be the most practical and efficent way to implement this in SQL? Looking for things like datatypes, type of search query(LIKE etc.) or any other ideas like a new combined field.

Already have code in and working fine but curious to learn better ways to implement it from programmers stronger at SQL.

Name: Anonymous 2008-07-02 17:33

Assuming that the search fields are all varchars of some length, do a query like this, replacing search_term with what you want to search for: select * from your_table where name like '%search_term%' or filename like '%search_term%' or comment like '%search_term%'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List