kr3m3r Posted August 21, 2007 Share Posted August 21, 2007 Hi guys, I'm trying to search my database for any rows in which one of the columns has part of the search term. It goes something like this: Search term foo. Select * from Library_Asset where UPC like %"foo" or Title like %"foo" or MajorAttribute like %"foo" or SecondaryAttribute like %"foo"; The php code I wrote is: $query = "select * from Library_Asset where UPC like '%".$searchterm."%'" or Title like '%".$searchterm."%'" or MajorAttribute like '%".$searchterm."%'" or SecondaryAttribute like '%".$searchterm."%'"; Which I'm pretty sure is awful. So any help you guys can give me would be incredibly appreciated. Thanks for your time -Robb Link to comment https://forums.phpfreaks.com/topic/66042-solved-select-query-help-use-of-like-to-find-stuff/ Share on other sites More sharing options...
fenway Posted August 21, 2007 Share Posted August 21, 2007 You can look into full-text indexing. Link to comment https://forums.phpfreaks.com/topic/66042-solved-select-query-help-use-of-like-to-find-stuff/#findComment-330452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.