mysql - delete one row by Specific ID which the same is not present another table Column ID -


mysql> select *from add_member; +-----------+-------------+--------------+-------------------+ | member_id | member_name | member_phone | member_department | +-----------+-------------+--------------+-------------------+ |     12345 | kishore     | 89482934     | it738             | |     12347 | ram         | 783892389    | it721829          | |    12346 | vardhan     | 902112       | ti5738            |  mysql> select *from ownbook;       +--------+----------+-----------+-------------+------------+-----------      | bookid | bookname | member_id | member_name |       |         |     +--------+----------+-----------+-------------+------------+------------+     |   1006 | physics  |     12346 | ram         | 2016-07-05 | 2016-07-20 |     +--------+----------+-----------+-------------+------------+------------+ 1 row in set (0.00 sec) 

you can try this:

delete add_member member_id  not exists(select member_id ownbook) 

or can use not in like

delete add_member member_id  not in(select member_id ownbook) 

if specific data do:

delete add_member  member_id  not in(select member_id ownbook member_id in(12345,12347)) 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -