简体   繁体   中英

how to use INNER JOIN and IN Clause in same query

i have three tables and want to run INNER JOIN and IN clause on them. can anyone tell me where i am doing wrong

    SELECT `tblinvoices`.id,`tblinvoices`.userid,`firstname`,`lastname`
            FROM `tblinvoices`
WHERE `paymentmethod`IN 
(SELECT  `gateway` FROM  `tblpaymentgateways` WHERE  `setting`='type' AND `value` = 'CC') 
INNER JOIN `tblclients` ON `tblinvoices`.userid=`tblclients`.id"

JOIN comes before WHERE:

SELECT     tblinvoices.id,
           tblinvoices.userid,
           firstname,
           lastname
FROM       
           tblinvoices

INNER JOIN tblclients
        ON tblinvoices.userid = tblclients.id
WHERE      
      paymentmethod IN
           (select gateway
            FROM   tblpaymentgateways
            WHERE  setting='type'
             AND   value = 'CC')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM