Hi,
I'm obviously missing something obvious here, so please excuse my ignorance, all help gratefully appreciated.
I'm working on a small stock management application. I have two tables in Mysql (Products & Products_Extra) Products contains the info we get from the supplier colour, size, barcode (which is the primary key for the table), Products_Extra is a table that contains our pricing info, shop category and the primary key is called FkeyBarcode.
I'm trying to find all the records in the Products table that are NOT in the Products_Extra table so that I can create a web page that the end user can then enter that information for multiple items at once based on say brand or productcode (e.g. one style of shoe may have several barcodes one for each size)
I know I'm going on a bit but I want to give you as much info as possible. So to the problem:
This query, rightly gives me the info for products that already have an entry in the Product_Extra table:
SELECT DISTINCT Products.Barcode, Products.StyleCode, Products.Size1, Products.Size2, Products.StyleDescription, Products.ColourDescription, Products.Brand FROM Products, Product_Extra WHERE Products.Barcode IN ('885290355470','885290355456') AND Products.Barcode = Product_Extra.FkeyBarcode
| Barcode | StyleCode | Size1 | Size2 | StyleDescription | ColourDescription | Brand |
| 885290355470 | A191956F | 34 | 38 | ERGO JEAN | VINTAGE | NULL |
Number of Results: 1
Which is the one entry from the two barcodes I do NOT want. So I try to exclude that barcode:
SELECT DISTINCT Products.Barcode, Products.StyleCode, Products.Size1, Products.Size2, Products.StyleDescription, Products.ColourDescription, Products.Brand FROM Products, Product_Extra WHERE Products.Barcode IN ('885290355470','885290355456') AND Products.Barcode != Product_Extra.FkeyBarcode
| Barcode | StyleCode | Size1 | Size2 | StyleDescription | ColourDescription | Brand |
| 885290355456 | A191956F | 34 | 34 | ERGO JEAN | VINTAGE | NULL |
| 885290355470 | A191956F | 34 | 38 | ERGO JEAN | VINTAGE | NULL |
Number of Results: 2
I know get the item I'm looking for but I'm still getting 885290355470 item which already has an entry in the product_extra table
As I said this is probably really obvious, but I'm just not getting it 🙂
Please help
Regards
Maurice