Maybe in the bottom part throw in a left join to T1 on part id where T1's part Id is null
SQL Union 2 tables, how to only return row from T1 if duplicate is found in T2, else show T2 rows
-
18-10-2022 - |
Pregunta
I'm having some trouble with a query in Access.
Current query:
SELECT 'Stock' as availablefrom, PartName, UnitPrice, Description, PartID, PartNumber
FROM PartsOnHand
UNION
SELECT 'Supplier', PartName, UnitPrice, Description, PartID, PartNumber
FROM Parts
ORDER BY PartName, PartID;
Which returns:
Availablefrom, PartName, PartID.. etc
Stock, Air Filter, 1
Supplier, Air Filter, 1
When I only want it to return the first result, from stock and ignore the second one, from supplier. Duplicates will only be present in the PartsOnHand table. all columns in the table are the same, except for the 'availablefrom' column made in this query
Cheers
No hay solución correcta
Otros consejos
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow