le007 Posted October 16, 2007 Share Posted October 16, 2007 WHERE (`type` like 'car') and WHERE (`type` like '%car%') ? Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/ Share on other sites More sharing options...
kernelgpf Posted October 16, 2007 Share Posted October 16, 2007 The percent signs make it so the word containing "car" can have surrounding characters.. the first would find something where type= "a car is cool" and the second could also find "racecars are awesome", whereas the first couldn't. Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371072 Share on other sites More sharing options...
le007 Posted October 16, 2007 Author Share Posted October 16, 2007 I have 2 different "types" - one is car and the other is caravan How can I make it just "car" is searched for? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371075 Share on other sites More sharing options...
GingerRobot Posted October 16, 2007 Share Posted October 16, 2007 The percent signs make it so the word containing "car" can have surrounding characters.. the first would find something where type= "a car is cool" and the second could also find "racecars are awesome", whereas the first couldn't. Actually, the first query would not match your first example. It would only match the exact text 'car'. It is no different from a query such as: WHERE `type` = 'car' le007: fyi, the % character is used to match any number of any character. You can use the underscore character to match any character, but just once. Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371076 Share on other sites More sharing options...
kernelgpf Posted October 16, 2007 Share Posted October 16, 2007 Oh. =P Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371078 Share on other sites More sharing options...
GingerRobot Posted October 16, 2007 Share Posted October 16, 2007 I have 2 different "types" - one is car and the other is caravan How can I make it just "car" is searched for? thanks! To search for just cars: SELECT * FROM `yourtable` WHERE `type`='car' For just caravans: SELECT * FROM `yourtable` WHERE `type`='caravan' Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371079 Share on other sites More sharing options...
le007 Posted October 16, 2007 Author Share Posted October 16, 2007 Ok thanks goys! Leo Quote Link to comment https://forums.phpfreaks.com/topic/73547-solved-whats-the-difference/#findComment-371082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.