Solved

T-SQL Using IN with a subquery

Posted on 2016-11-23
3
52 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 13

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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