I have 4 tables. (Simplified the 4 tables for the question)
Table 1: Supplier - Id, Type, TypeId, ExpiryDate
Table 2: SupplierType1 - Id, UserId, SupplierName
Table 3: SupplierType2 - Id, UserId, SupplierName
Table 4: User - Id, Name
All Id's are simply auto-increments in their tables.
In Supplier: 'Type' refers to either SupplierType1 or SupplierType2
'TypeId' is the 'Id' from either SupplierType1 or SupplierType2.
In both SupplierType1 and SupplierType2: 'UserId' is the Id from User
I have the 'UserId' (shown as X below). I want to return a list of which has these columns: Supplier.Id, SupplierType1.RetailName, ExpiryDate
Where (SupplierType1.UserId == 'X' AND Supplier.TypeId == SupplierType1 AND Supplier.ExpiryDate < CurrentDate)
I've only recently starting using mysql and my current solutions seem way too cumbersome. Keen to learn a better way to do this. I would appreciate the help. Thanks in advance!