开发者

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

i get 2 names as the开发者_如何学Python 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....


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)  


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'))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜