chronister Posted November 7, 2008 Share Posted November 7, 2008 Hello all, I have a question about a query I am trying to get completed... I have a script that dynamically builds a query such as this... SELECT * FROM dayEnd WHERE store= 'Store1' || store= 'Store2' || store= 'Store3' && businessDate BETWEEN '11/01/2008' AND '11/03/2008' ORDER BY store, businessDate this is only returning the first 2 items.... e.g. store1 and store2.... I am pretty sure that I can do something like this as I thought I had done it before.. What do I need to do in order for all the items to be returned?? Would it be better to use something like this?? ....... WHERE store IN ('storeArray') Thanks for the help.. Nate Quote Link to comment https://forums.phpfreaks.com/topic/131829-solved-where-clause-with-multiple-items/ Share on other sites More sharing options...
chronister Posted November 7, 2008 Author Share Posted November 7, 2008 I answered my own question..... Seems as though a where clause will only take 2 arguments ..e.g. WHERE this=that OR that=this or WHERE a=b && c=d The solution was to create an array of items and use the IN clause WHERE store IN ('store1', 'store2','store3').... this returns all data to me whether there is 1 item or 10 items. Quote Link to comment https://forums.phpfreaks.com/topic/131829-solved-where-clause-with-multiple-items/#findComment-684820 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.