I get an error message with a SQLState = 42920, which says that you can't have a Group By clause in an embedded Select statement. My problem is that I can have multiple tbl2.fldB values for each tbl2.fldA value. If I don't restrict it somehow I get an error that the subselect is returning multiple values. I am not sure how to frame the SQL to get what I want.
Here is my SQL as I am currently trying to run it.
UPDATE tbl1
SET (tbl1.fldA, tbl1.fldB) =
(SELECT tbl2.fldA, MIN(tbl2.fldB)
FROM tbl2
WHERE tbl2.fldC = tbl1.fldC
AND tbl2.fldD = tbl1.fldD
AND tbl2.fldE = tbl1.fldE
AND tbl2.fldF = tbl1.fldF
AND Exists
(SELECT 1 From tbl2
WHERE tbl2.fldC = tbl1.fldC
AND tbl2.fldD = tbl1.fldD
AND tbl2.fldE = tbl1.fldE
AND tbl2.fldF = tbl1.fldF)
GROUP BY tbl2.fldA);
Here is my SQL as I am currently trying to run it.
UPDATE tbl1
SET (tbl1.fldA, tbl1.fldB) =
(SELECT tbl2.fldA, MIN(tbl2.fldB)
FROM tbl2
WHERE tbl2.fldC = tbl1.fldC
AND tbl2.fldD = tbl1.fldD
AND tbl2.fldE = tbl1.fldE
AND tbl2.fldF = tbl1.fldF
AND Exists
(SELECT 1 From tbl2
WHERE tbl2.fldC = tbl1.fldC
AND tbl2.fldD = tbl1.fldD
AND tbl2.fldE = tbl1.fldE
AND tbl2.fldF = tbl1.fldF)
GROUP BY tbl2.fldA);