0

I am trying to insert all data from one table to another in postgreSQL but do not why I keep running into this error. Can someone please help out here.

mysql - move rows from one table to another

insert into rejected
select * from data 
where Actual_Sale_Date = '03/08/2015' 
and Last_Name_First_Name = 'Cindy' 

Error:

ERROR:  INSERT has more expressions than target columns
LINE 3: select * from data
Community
  • 1
  • 1
Jason Smith
  • 127
  • 1
  • 3
  • 14
  • 7
    *Always* list the columns when you are doing an insert, both for the `insert` and the `select`. The problem will then go away and your code will be safer and clearer. – Gordon Linoff Jan 10 '17 at 17:02
  • Thanks, but the MySQL linked I have attached utilizes the * in the snippet. Is * possible in postgreSQL? – Jason Smith Jan 10 '17 at 17:03
  • 2
    It's possible, as long as the two tables have the same data structure. Having said that, why not simply add a new column to data called status, or something like that. – Dan Bracuk Jan 10 '17 at 17:06
  • The rejected is exactly the same structure as the data table. That is the very reason for the asterisk. – Jason Smith Jan 10 '17 at 17:07
  • 5
    If the two tables had the same data structure, you would not get that error message. – Dan Bracuk Jan 10 '17 at 17:08
  • Thanks I got my mistake now, there is a serial primary key inserted. – Jason Smith Jan 10 '17 at 17:09

0 Answers0