0

Subquery returns more than 1 row on this SQL statement:

UPDATE bar
SET bar.bar_id = CONCAT(CONCAT(
    (select

        west.west_id

        from west
    where bar.west_id = west.id),
     ':'), (select bar.number from bar))

I want to update the column with (west.west_id):(bar.number) but when I run this I get a Subquery returns more than 1 row. If I go to one concat statement and remove (select bar.number from bar) then it runs correctly and updates to (west.west_id): but I need to include the bar.number at the end as well. Thanks!

  • 1
    It means that the last query bar.number from bar returns more than one rows (as the message says). What do you want happen to bar.bar_id when this happens? – tinazmu Sep 01 '22 at 03:16
  • Could you pls provide some sample data and expected result? As for now, I can tell that this subquery select bar.number from bar returns more than one row. Do you need any filter here? – learning Sep 01 '22 at 08:49
  • I'm agree with @tinazmu there's a problem with (select bar.number from bar) you have to specify which bar.number you wanted to – brian marcius Sep 02 '22 at 03:02

0 Answers0