How would I get records from a table, with not matching IDs from another table

How would I get records from a table, with not matching IDs from another table

Firstly I would like to say that I am sorry if it is a duplicate, I really did not find anything that would help me. I am quite new to real SQL development, so if somebody could even point me to some resources I would very much appreciate it.

Firstly I would like to say that I am sorry if it is a duplicate, I really did not find anything that would help me. I am quite new to real SQL development, so if somebody could even point me to some resources I would very much appreciate it.

Problem:

I am not sure how to handle things, I suspect the need of UNION and LEFT OUTER JOIN.

Summary:

Table1: user1 history of viewed articles (1 column with article IDs)

Table2: user2 history of viewed articles (1 column with article IDs)

Table3: articles (more columns has IDs)

Now I would like an UNION between user1 and user2 history and get the IDs of articles that both have not seen yet limited to 10.

Pseudo code:

(SELECT * FROM user1
UNION 
SELECT * FROM user2) as UnionTable

SELECT top(10) * FROM article WHERE UnionTable.id <> article.id

OR

SELECT * FROM articles LEFT OUTER JOIN UnionTable

The expected outcome is a list of article IDs that are not found in the union table. Are there any other better ways? Subqueries or procedures?

sql sql-server

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

SCHEMAS in SQL Server -MS SQL Server – Zero to Hero Query Master

This is part 3 of “MS SQL Server- Zero to Hero” and in this article, we will be discussing about the SCHEMAS in SQL SERVER. Before getting into this article, please consider to visit previous articles in this series from below.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Welcome Back the T-SQL Debugger with SQL Complete – SQL Debugger

Debug SQL stored procedures and develop your SQL database project with dbForge SQL Complete, a new add-in for Visual Studio and SSMS. When you develop large chunks of T-SQL code with the help of the SQL Server Management Studio tool, it is essential to test the “Live” behavior of your code by making sure that each small piece of code works fine and being able to allocate any error message that may cause a failure within that code.

The Easy Guide on How to Use Subqueries in SQL Server

This article provides an outlook on various types of subqueries in SQL such as select or other T-SQL statements and caveats when using them.