Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

How to write sql subqueries

$
0
0

Can anyone help me out.
 
I want to select the "productid" for all products from a table called "products" that both "user1" and "user2" have purchased

I am using 

ALTER PROCEDURE test
(@user1 as int, @user2 as int)

AS

Select  productid from (Select productId
            From products
            Where productid=@user1)
           
WHERE productid=@user2

I am getting an incorrect syntax around the word "Where" message.

Can anyone tell me the correct syntax for this

Many thanks

Martin


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>