Home > Software design >  How to Read Data Compare of two table
How to Read Data Compare of two table

Time:05-21

I Have Two Tables , Table1 Contains 10 Users Regular Data, Table2 Contains 3 vip users username(same as table1) only . Now how can I Get All 7 Non-VIP Users data using sql? Platform IS sqlite Database Android

CodePudding user response:

Something like:

SELECT * from Table1
WHERE user_id
NOT IN (SELECT user_id from Table2);

Translating to: Select everything in Table 1 where user_id doesn't exist in list of user_id's from Table2.

CodePudding user response:

Somnath, It would be great if you would provide the database platform and actual table schemas in your question. Not having this information requires people to make assumptions. Anyway, I think it would like like this.

select *
from table1
where not exists(select * from table2 where table2.username = table1.username)
  • Related