user2942436
user2942436

Reputation: 1

Error 1064 - SQL syntax for an INSERT statement

I'm trying to execute this query:

insert into lvl.tb_jogos a (a.Tags,a.Nome,a.Descricao,a.IdCategoria,a.Tipo)
values
(
  (select b.keywords,b.name,b.`desc`,b.cat,b.`type`
   from level2.games b, lvl.tb_jogos a
   where b.name LIKE `%12 Holes of X-Mas%`
  )
)

But SQL return this message:

Error SQL (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right symtax to use near 'a(a.Tags,a.Nome,a.Descricao,a.IdCategoria,a.Tipo) values ( (select b.keywords at line 1

Can you help me?

Upvotes: 0

Views: 58

Answers (2)

mvp
mvp

Reputation: 116048

Replace backticks with single quotes, from this:

LIKE `%12 Holes of X-Mas%`

to this:

LIKE '%12 Holes of X-Mas%'

Also remove extra VALUES and parentheses. Your statement should be:

INSERT INTO lvl.tb_jogos (Tags, Nome, Descricao, IdCategoria, Tipo)
SELECT b.keywords, b.name, b.desc, b.cat, b.type
FROM level2.games b, lvl.tb_jogos a
WHERE b.name LIKE '%12 Holes of X-Mas%'

Upvotes: 0

Naftali
Naftali

Reputation: 146302

Remove the word VALUES and then you should be good.

Upvotes: 1

Related Questions