I want to get the ID's of [interactions] table but these ID's must not equal to [EmailOUT] table. I couldn't write the query.
Select ID from EmailOut
where ID NOT IN
(select ID from
[172.28.101.120].[GenesysIS].dbo.interactions
where media_type = 'email'
and type = 'Outbound')
something similar to this. I want Outbound Emails in Interactions table but these emails may exist in EmailOut table. I want to remove them. Outbound Email count about 300 but this query result should less than 300
Scenario: Get the price of the product where the supplier is not ABC. Query: SELECT ProductPrice FROM Product WHERE ProductName NOT IN (SELECT ProductName FROM Supplier WHERE SupplierName = "ABC"); That's all for SQL IN and SQL NOT IN operator examples.
SQL NOT EXISTS in a subqueryNOT EXISTS is used with a subquery in the WHERE clause to check if the result of the subquery returns TRUE or FALSE. The Boolean value is then used to narrow down the rows from the outer select statement.
IN, NOT IN operators in SQL are used with SELECT, UPDATE and DELETE statements/queries to select, update and delete only particular records in a table those meet the condition given in WHERE clause and conditions given in IN, NOT IN operators. I.e. it filters records from a table as per the condition.
SQL Not Equal (<>) Operator In SQL, not equal operator is used to check whether two expressions are equal or not. If it's not equal, then the condition will be true, and it will return not matched records. Both != and <> operators are not equal operators and will return the same result, but the !=
It seems you should reverse your query, if you want to get the ID's of [interactions] table:
select ID from
[172.28.101.120].[GenesysIS].dbo.interactions
where media_type = 'email'
and type = 'Outbound'
AND ID NOT IN (SELECT ID FROM EmailOut)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With