We help IT Professionals succeed at work.
Get Started

sql 2008  sub query

845 Views
Last Modified: 2012-08-13
I HAVE TWO TABLES.  AND ORDER TABLE AND A PRODUCTS TABLE.  THE ORDERS TABLE HAS THE ORDER ID AND THE ShipVia INFORMATION CONTAINED IN IT.  
THE PRODUCTS TABLE HAS THE PRODUCT NAME  AND PRODUCT ID CONTAINED ON THIS TABLE.
I WAS TRYING TO REPLY TO THIS REQUEST:
Write a subquery that shows all of the products that were shipped via the same method as OrderID 10248.
The shippedVia field contains one digit numbers on the Orders table from 1 to 5.
THIS IS THE CODE I TRIED TO CREATE:

SELECT *
FROM Products
WHERE EXIST (SELECT * FROM Orders WHERE ShipVia = 3)
THIS IS THE ERROR MESSAGE I RECEIVED
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'SELECT'.
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ')'.

WHERE AM I MAKING MY MISTAKES AND WHAT WOULD BE THE CORRECT SYNTAX?
Comment
Watch Question
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE