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
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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.