webref.eu Posted June 2, 2009 Share Posted June 2, 2009 Hi All I have the following MySQL query: $query = "select * from Products where (ProductName like \"%$trimmed%\" or ProductBrand like \"%$trimmed%\") order by ProductName"; I want to modify it to include an or ProductDesc like \"%$trimmed%\, so how do I do this? Thanks Link to comment https://forums.phpfreaks.com/topic/160688-solved-help-me-modify-this-mysql-query/ Share on other sites More sharing options...
webref.eu Posted June 2, 2009 Author Share Posted June 2, 2009 I tried changing it to this: $query = "select * from Products where (ProductName like \"%$trimmed%\" or ProductBrand like \"%$trimmed%\ or ProductDesc like \"%$trimmed%\") but it doesn't like that. Rgds Link to comment https://forums.phpfreaks.com/topic/160688-solved-help-me-modify-this-mysql-query/#findComment-848019 Share on other sites More sharing options...
Alex Posted June 2, 2009 Share Posted June 2, 2009 $query = "select * from Products where (ProductName like \"%$trimmed%\" or ProductBrand like \"%$trimmed%\" or ProductDesc like \"%$trimmed%\"); Link to comment https://forums.phpfreaks.com/topic/160688-solved-help-me-modify-this-mysql-query/#findComment-848020 Share on other sites More sharing options...
Maq Posted June 2, 2009 Share Posted June 2, 2009 You don't need parentheses or to escape the double quotes. The conventional way is to use single quotes around the pattern. $query = "SELECT * FROM Products where ProductName LIKE '%$trimmed%' or ProductBrand LIKE '%$trimmed%' or ProductDesc LIKE '%$trimmed%'"; Link to comment https://forums.phpfreaks.com/topic/160688-solved-help-me-modify-this-mysql-query/#findComment-848025 Share on other sites More sharing options...
webref.eu Posted June 2, 2009 Author Share Posted June 2, 2009 You don't need parentheses or to escape the double quotes. The conventional way is to use single quotes around the pattern. Thanks, changing as you suggested made it work. Thanks for the other reply too. Rgds Link to comment https://forums.phpfreaks.com/topic/160688-solved-help-me-modify-this-mysql-query/#findComment-848038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.