Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql values not in another table

-- Find missing t1 values in t2 (based on 'id' field)
SELECT * FROM t1 WHERE t1.id NOT IN (SELECT id FROM t2);
-- or
SELECT * FROM t1 WHERE NOT exists (
    SELECT NULL FROM t2 WHERE t2.id = t1.id
);
-- or
SELECT t1.* FROM t1 LEFT OUTER JOIN t2 ON t2.id = t1.id WHERE t2.id IS NULL;
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql start command 
Sql :: mysql create database with collation 
Sql :: postgres group by 10 minute intervals 
Sql :: sql order by ascending 
Sql :: current year sql 
Sql :: postgresql how to show table names 
Sql :: insert data in pgsql 
Sql :: sql server set variable if exists 
Sql :: begin transaction in sql 
Sql :: mysql add root password 
Sql :: postgresql create schema in specific database 
Sql :: postgres default user 
Sql :: 2nd highest salary in mysql 
Sql :: oracle replace 
Sql :: mysql trim 
Sql :: (PDOException(code: 2002): SQLSTATE[HY000] [2002] Permission denied at 
Sql :: reseed sql table primary key 
Sql :: oracle drop temporary table 
Sql :: backup a table in sql 
Sql :: how to drop all tables in postgresql 
Sql :: t-sql merge example 
Sql :: sql_calc_found_rows 
Sql :: like in mysql 
Sql :: recently updated stored procedure in sql server 
Sql :: select last row in sql 
Sql :: oracle remove line breaks 
Sql :: java sql timestamp now 
Sql :: update auto increment value in mysql 
Sql :: temp table vs variable table in sql server 
Sql :: oracle list grants on procedure 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =