I'm building a database for a small bookshop with a PHP web interface. For this problem I want to display all records in the 'products' table (prod_core) without those that have a value in the products field 'barcode' equal to the 'description'field in the 'sales' table (inc_core).
I actually managed to get this working for the first 'sales' mutation, but whenever I add a second record to the 'sales' table, the query doesn't work any more. (except for the first record added). This is my SQL code:
SELECT prod_core.prodID, prod_core.title, prod_core.location, prod_core.genre, prod_core.price, prod_core.barcode FROM prod_core WHERE prod_core.barcode NOT IN ( SELECT `description` FROM inc_core GROUP BY prod_core.prodID)
I suppose it has something to do with SQL not looping (it stops searching the table for records that match the requirements) but I'm not sure. I would very much appreciate any help!