Hi have a 2 tables organized in this way:
table_users
|user_id|username|
table_products
|product_id|user_id|
Now, I have some orphan entries in 'table_products'. With this query I check how many products I have:
SELECT count(product_id) FROM table_products
This query show me the number of the products associated to the users:
SELECT p.product_id, u.username
FROM table_products AS p
JOIN table_users AS u ON u.user_id = p.user_id
I need a query that allow me to select and remove all the orphans products. Anyone can help me ?