company_services +----+------+--------------+ | id | name | company_id| +----+------+--------------+ | 1 | IT services| 102| +----+------+--------------+ | 2 | hardware| 105| +----+------+--------------+ company_products +----+------+--------------+ | id | title| company_id | +----+------+--------------+ | 1 | Mouse| 101| +----+------+--------------+
+----+------+--------------+ | 2 | Keyboard| 102| +----+------+--------------+
SELECT count(*)FROM company_services WHERE company_id NOT IN (SELECT company_id FROM company_products)
Result Count=1
Related Queries
select records from one table that don’t exist in another,
find records in one table that are not in another,
sql find records in one table that are not in another,
delete rows from one table that exist in another,