How to pass the result of the first query (which has two values) as input to the second?

I get 2 names as the output of the first request .... for example: paul, peter now this should be the input for the second request, which should display the paul and peter identifiers of the email ....

+5
source share
3 answers

For nested queries, I highly recommend a suggestion WITH. This makes complex complex queries an order of magnitude easier to understand / build / modify:

WITH 
   w_users AS( -- you can name it whatever you want
      SELECT id
        FROM users
       WHERE < long condition here >
   ),
   w_other_subquery AS(
      ...
   )
SELECT email_id
  FROM ...
 WHERE user_id IN (SELECT id FROM w_users)  
+5
source

You can use this as

AS

SELECT USER_ID,EMAIL_ID FROM USERS where user_id IN 
(SELECT PRODUCT_MEMBERS FROM PRODUCT WHERE PRODUCT_NAME='ICP/RAA');

Just use the IN '=' parameter to match one result

+4
source

In Command :

SELECT  email FROM tableName WHERE (Name IN ('paul', 'peter'))
+1

All Articles