I have three tables Orders, CustomerProductSizesOptions and ProductSizesOptions.
Orders:
| OrderID | SurName | DeliveryDate |
|---|---|---|
| 45 | Jones | 01/01/2025 |
| 43 | Smith | 04/02/2025 |
CustomerProductSizesOptions:
| OrderID | ProductOptionSizeID | CustomerProductSizeOptionID |
|---|---|---|
| 45 | 216744 | 695746 |
| 43 | 225622 | 690056 |
| 43 | 209876 | 654345 |
ProductSizesOptions:
| ProductOptionSizeID | ProductOptionID |
|---|---|
| 216744 | 1627 |
| 225622 | 3456 |
We have an orders database, and I want to query a ProductOptionID and return OrderIDs, Surname and DeliveryDate where that order has that particular ProductOptionID on it. For example, ProductOptionID = 1627.
I'm struggling to get my joins to work, can anyone help? I know I can use 'DISTINCT' after SELECT, to return just one instance of each orderID which will be useful.