Apologies if the title does not accurately describe the question (which it probably doesn’t). I have the following two tables :-
tLiveTable:
PieceID LocationRef
------------------------
100 5
tPieceTable:
ID BatchNo PieceNumber
------------------------------
50 ABC X1
100 ABC X1
How can I update the LocationRef for that piece in tLiveTable given only the BatchNo and PieceNo?
I’ve tried the following:
UPDATE tLiveTable
SET LocationRef = 'blabla unimportant'
WHERE
PieceID = (SELECT ID FROM tPieceTable WHERE (BatchNo = 'ABC') AND (PieceNo = 'X1'))
But there can be multiple entries in tPieceTable with an identical BatchNo and PieceNo. I want to only retrieve the ID from tPieceTable whose ID is currently the one in the tLiveTable.
Should I really be using an INNER JOIN for this?
Your query will not work as
SELECT ID FROM tPieceTable WHERE (BatchNo = 'ABC') AND (PieceNo = 'X1')returns more than one IDTry this;
Or using
INfor=