Ank
Ank

Reputation: 6270

MySQL insert query error

Whats wrong with this query. I'm getting an error saying

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Item 1') where ItemName like 'Item 1' at line 1

My query is

insert into newitem (QuantityAvailable) values 
(Select count(*) from  addtoinventory where ItemName like 'Item 1') 
where ItemName like 'Item 1'

Upvotes: 0

Views: 87

Answers (2)

demo.b
demo.b

Reputation: 3449

insert into newitem (QuantityAvailable) Select count(*) from addtoinventory where ItemName like '%Item 1%'

Upvotes: 0

Gary
Gary

Reputation: 78

Take out the word values from your query.

Also, I don't see what you expect the where clause to do in the outer query. If you haven't inserted a value yet, how can you compare it to anything? If you have, then the inner where clause takes care of that.

Upvotes: 3

Related Questions