Reputation: 27
I am working with oracle (with Toad) but when I try to execute this query
INSERT INTO KEYUSER(NAME) VALUES(UNAME) WHERE ID = 1;
I get this error:
SQL command not properly ended. Found 'WHERE' expecting ;-or- LOG -or- RETURN RETURNING
What is wrong? Regards.
Upvotes: 0
Views: 966
Reputation: 1269443
Presumably, you intend an UPDATE
rather than INSERT
:
UPDATE KEYUSER
SET NAME = UNAME
WHERE ID = 1;
Sometimes new users of SQL get confused between INSERT
and UPDATE
. INSERT
inserts new rows into a table. UPDATE
changes values in existing rows. The confusion is become some people interpret INSERT
as "inserting new values into a row".
Upvotes: 0
Reputation: 32003
General Insert statement is like below
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
So in your case you have to remove where
clause from your statement and query will be like below
INSERT INTO KEYUSER(NAME) VALUES('UNAME');
Upvotes: 1
Reputation: 2592
You can never use where clause in insert statement. It does not make any sense to have it while you are simply trying to insert a row.
Upvotes: 3