Solved

T-SQL Using IN with a subquery

Posted on 2016-11-23
3
12 Views
Last Modified: 2016-11-23
Using IN with a subquery
https://msdn.microsoft.com/en-us/library/ms177682.aspx

I'm using the IN from the above link

I'm using sql server Northwind database

When I run this query

-- Determines whether a specified value matches any value in a subquery or a list.
SELECT * FROM [Northwind].[dbo].[Orders]
WHERE [CustomerID] IN(
                      SELECT * FROM [Northwind].[dbo].[Customers]                            
                     )


I get this error

"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."

Any idea of why i'm getting this error
0
Comment
Question by:maqskywalker
3 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 250 total points
ID: 41899553
You need to specify what column you are looking for CustomerID in instead of using SELECT *
1
 
LVL 12

Assisted Solution

by:Jeff Darling
Jeff Darling earned 250 total points
ID: 41899649
like this

SELECT * FROM [Northwind].[dbo].[Orders]
WHERE [CustomerID] IN(
                      SELECT CustomerID FROM [Northwind].[dbo].[Customers]                             
                     )

Open in new window

0
 
LVL 1

Author Closing Comment

by:maqskywalker
ID: 41899680
thanks
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now