2

I'm trying to copy data from one DB into another on the same server. For this I'm using a bash script:

mysql -uroot -pMYPW -D "ucb-pvapp" -e "insert into app_daily_quartiles (postcode, lo_limit, hi_limit, median) select (PLZ, loLimit, hiLimit, median) from solarlogmesswerte.tagesquartilekleinraum2"

I tried using the dbDest.table notation for the destination too but that gave me an error.

Now I get. ERROR 1241 (21000) at line 1: Operand should contain 1 column(s)

But I'm not able to find the error.

Using version: 8.0.23-0ubuntu0.20.04.1

why me
  • 301
  • 1
  • 2
  • 15

1 Answers1

1

Remove brackets from select. So it should go like

insert into app_daily_quartiles (postcode, lo_limit, hi_limit, median) 
select PLZ, loLimit, hiLimit, median from solarlogmesswerte.tagesquartilekleinraum2
Adam Tokarski
  • 659
  • 4
  • 13
  • Thanks! That did the trick. Could you explain why? – why me Feb 24 '21 at 10:40
  • 1
    Probably mysql tries to treat that as subquery (https://dev.mysql.com/doc/refman/5.6/en/subquery-errors.html) or as a row constructors (https://dev.mysql.com/doc/refman/5.6/en/row-subqueries.html). – Adam Tokarski Feb 24 '21 at 10:45