Question

i get 2 names as the output of the first query.... eg: paul,peter now this should be the input for the second query, which has to display paul's and peter's email ids....

Was it helpful?

Solution

For nested queries I would strongly recommend WITH clause. It makes long complex queries order of magnitude easier to understand / construct / 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)  

OTHER TIPS

You can use like this

LIKE

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 clause '=' is used for matching one result

You can use In Command to get result ex:

SELECT  email FROM tableName WHERE (Name IN ('paul', 'peter'))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top