Jump to content

[SOLVED] Where clause with multiple items.


chronister

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/131829-solved-where-clause-with-multiple-items/
Share on other sites

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.