Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 WHERE for array?

Author  Topic 

nikl
Starting Member

7 Posts

Posted - 2012-08-27 : 08:25:48
Firstly, sorry if this is the wrong section, maybe even the entirely wrong place for this. I am new to both phpmyadmin and sql and honestly have no idea, what category my problem best fits into and if it even belongs here at all.

I am trying to fetch all orders with a specific payment method from my database. This

SELECT `entity_id` FROM `sales_flat_order_payment` WHERE method = "cashondelivery"

will fetch the entity IDs of all relevant orders.
Another column includes these entity IDs next to the actual order numbers. So I am trying to find a way to fetch all entries from this second column, whose entity ID is included in the list of entity IDs fetched in the first step.
So basically I am looking for something like this:

SELECT `increment_id` FROM `sales_flat_order` WHERE entity_id = "<array of ids>"

Is something like that supported?
Thank you in advance!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-08-27 : 08:44:29
where entity_id IN(here comes your first select)


Too old to Rock'n'Roll too young to die.
Go to Top of Page

nikl
Starting Member

7 Posts

Posted - 2012-08-28 : 13:05:37
It seems so easy, now that I've seen the solution :)
Thank you so much!
Go to Top of Page
   

- Advertisement -