suohryu Posted September 22, 2008 Share Posted September 22, 2008 Hi all i been looking all over the web for a answer and failed at it so i thought ill asked the question in case it has never come up so i have a php/sql query that looks like so $quicksearch = "6168,6123,6132" SELECT * FROM `coupons` WHERE `codes` IN ($quicksearch) now i have a field in the coupon table with the value 6126,6168 now if i change the above $quicksearch to look for 6126 instead of 6168 it return the field but the code above returns 0 is there some way to implement a Like clause into the above so that it will return the field look forward to the replies Quote Link to comment https://forums.phpfreaks.com/topic/125297-a-question-about-in-statements/ Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 You could explode the string by commas and search each piece. This would take a little longer in the query but would work. Quote Link to comment https://forums.phpfreaks.com/topic/125297-a-question-about-in-statements/#findComment-647851 Share on other sites More sharing options...
suohryu Posted September 23, 2008 Author Share Posted September 23, 2008 thanks for the reply... would you be able to explain the idea a bit for me and maybe a simple example would be wonderful because i think i understand what your saying but not 100% sure are you saying i need to explode the code field for each result i have Quote Link to comment https://forums.phpfreaks.com/topic/125297-a-question-about-in-statements/#findComment-648301 Share on other sites More sharing options...
fenway Posted September 29, 2008 Share Posted September 29, 2008 You really shouldn't be storing lists in single fields. Quote Link to comment https://forums.phpfreaks.com/topic/125297-a-question-about-in-statements/#findComment-653300 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.