Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the table of missing rows in mysql

Tags:

mysql

i have two mysql tables

tableA

colA1   colA2
1       whatever
2       whatever
3       whatever
4       whatever
5       whatever
6       whatever

second table is basically derived from tableA but has some rows deleted

tableB

colB1    colB2
1       whatever
2       whatever
4       whatever
6       whatever

how can i write an query to obtain the table of missing rows from the above two tables

i.e

colC1   colC2
3      whatever
5      whatever
like image 456
silverkid Avatar asked Mar 11 '10 12:03

silverkid


People also ask

How do I find missing values in MySQL?

To look for NULL values, you must use the IS NULL test. The following statements show how to find the NULL phone number and the empty phone number: mysql> SELECT * FROM my_table WHERE phone IS NULL; mysql> SELECT * FROM my_table WHERE phone = ''; See Section 3.3.

Which is used to retrieve No of rows in MySQL table?

The COUNT() function is an aggregate function that returns the number of rows in a table. The COUNT() function allows you to count all rows or only rows that match a specified condition. The COUNT() function has three forms: COUNT(*) , COUNT(expression) and COUNT(DISTINCT expression) .

How do I see the rows in a MySQL table?

The first command you will need to use is the SELECT FROM MySQL statement that has the following syntax: SELECT * FROM table_name; This is a basic MySQL query which will tell the script to select all the records from the table_name table.


1 Answers

SELECT t1.*
FROM TableA t1 LEFT JOIN
     TableB t2 ON t1.ID = t2.ID
WHERE t2.ID IS NULL
like image 140
Adriaan Stander Avatar answered Oct 12 '22 23:10

Adriaan Stander