I'd like to implement an antijoin on two table but using two keys so that the result is all rows in Table A that do not contain the combinations of [key_1, key_2] found in Table B. How can I write this query in SQL?
SQL antijoin with multiple keys
377 Views Asked by mdrishan At
2
There are 2 best solutions below
Related Questions in SQL
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
- How to create nested selects with sql?
- Pull and push data from and into sql databases using Excel VBA without pasting the data in Excel sheets
- Best Practice for adding columns to a Table in Oracle database
- SQL FIFO STACK using two tables
- SQL Query - Order by String (which contains number and chars)
Related Questions in SUBQUERY
- show duplicate values subquery mysql
- Number of string occurrences
- oracle sql compare result two subselects
- SQL alternative to double subquery
- Postgresql : Check if the last number is the highest
- How to insert a query into another query in C# using Microsoft Visual Studio?
- oracle insert into column using subquery
- MySql select data from multiple tables - several sub records expected
- MySQL select and count 2 colums with different where clauses
- SQL subqueries ques :
- What is the difference between subquery and a joined subquery?
- SQL find references with single occurrences
- parse.com - Nested query and Join Table
- Problems With FOR XML AUTO
- Building an SQL query for GROUP_CONCAT-ing multiple one/many-to-many tables
Related Questions in LEFT-JOIN
- left join two tables in same DataContext LinQ in c#
- join 2 tables and get some columns from 1st table and max timestamp value from second table
- PHP Select Count and Left Join where
- Query results are multiplied by 2
- Query to join two tables by mapping third table without returning all records from third table in Oracle
- SUM of rows with GROUP CONCAT and LEFT JOIN
- Caused by: java.sql.SQLSyntaxErrorException: [SQL0205] Column MITMAS_MMCONO not in table OOLINE in schema
- 'Arftul Software' 'Find sequence starts and ends' with Dates
- linq multi left join to same property
- LEFT JOIN with condition is not returning data desired
- Limit left join to 1
- LINQ many to many relationship - get a list of grouped objects
- MySQL: Remove JOIN for Matched Row if 2nd Round of Criteria Not Met
- Laravel 2 table join with all from left table merged with members of the right table with a given FK value
- Joining product attributes table with the product table to display product
Related Questions in ANTI-JOIN
- Oracle - Finding missing /non-joined records
- how to find what is in data frame and not another in R
- SQL antijoin with multiple keys
- Using information from one table to find if the info exists in another table
- SQL Anti-join Delete Optimisation
- Master view of multiple dataframes with common columns
- Use multiple columns as identifiers while comparing two data frames in R using setdiff
- Spark Dataset when to use Except vs Left Anti Join
- how to anti_join only if entire row is similar r
- anti_join is not recognizing tidytext stop words in my dataset
- Spark Dataframe leftanti Join Fails
- Anti join followed by union in Spark SQL
- Is there any objective reason to prefer a particular form of left anti-semi join?
- report the names of all sellers who did not make any sales in 2020
- Using Left Anti Join in SQL
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?



If you want an anti-
left join, the logic is:As for me, I like to implement such logic with
not exists, because I find that it is more expressive about the intent:The
not existsquery would take advantage of an index ontableb(key_1, key_2).