0

I'm trying to insert in Table2 multiple rows with multiple columns from Table1, but while doing so, I'm editing some of the values going into Table2. Both are large tables (several million rows). Here's the query:

insert into table2 (board_id,title,content,domainurl)
select (id, replace(title, '_', ' '), description, CONCAT("http://somesite.com/", title))
from table1

When running this query, shouldn't the insert start happening right away (being that I'm not doing a join)? I've started the query several minutes ago (phpmyadmin still shows "loading") but I don't see any rows being added to table2...?

EDIT: The query just stopped with the message "#1241 - Operand should contain 1 column(s)". I have no idea what that means!

Phil
  • 1,719
  • 6
  • 21
  • 36

2 Answers2

1

Try this:

INSERT INTO table2 (board_id,title,content,domainurl)
SELECT 
  id AS board_id, 
  REPLACE(title, '_', ' ') AS title, 
  description AS content, 
  CONCAT("http://somesite.com/", title) AS domainurl 
FROM table1
Dave S.
  • 6,349
  • 31
  • 33
0

As per here all I had to do is remove the parenthesis from the SELECT clause.

select id, replace(title, '_', ' '), description, CONCAT("http://somesite.com/", title)

worked perfectly and fast!

Community
  • 1
  • 1
Phil
  • 1,719
  • 6
  • 21
  • 36