Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

T-SQL Using IN with a subquery

Posted on 2016-11-23
3
Medium Priority
?
64 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 1000 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 1000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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