cvbn402517
cvbn402517

Reputation: 19

Openquery within openquery

Is that possible to do a openquery within an openquery?

I have error while calling the openquery from MySQL Workbench via SQL Server from the following:

select * from openquery ([ABS],
         'select * from sales_payments 
          where receipt_id not in 
                (select * from openquery ([ABS], ''select distinct receipt_id from receipt''))
         ')

Upvotes: 0

Views: 388

Answers (1)

Amira Bedhiafi
Amira Bedhiafi

Reputation: 1

Why not using INNER JOIN instead of NOT IN?

SELECT * FROM openquery ([ABS],
     'SELECT * FROM sales_payments AS s
     INNER JOIN  receipt AS r 
     ON s.receipt_id =r.receipt_id
     WHERE r.receipt_id IS NULL')

Or simply :

SELECT * FROM openquery ([ABS],

'SELECT * FROM sales_payments AS s
 WHERE s.receipt_id NOT IN  (SELECT distinct receipt_id FROM receipt)')

Upvotes: 1

Related Questions