Reputation: 7
How to use WHERE clause while inserting values into the table?
I tried the below query to insert values into the column, whichever set address='COB'
insert into table empt (loc,country,mob)
values ('&loc','&country',&mob)
where address='COB';
Upvotes: 0
Views: 85
Reputation: 16
insert into table empt (loc,country,mob)
select loc,country,&mob
where address='COB';
Upvotes: 0
Reputation: 367
I don't know, why you are using "Table" in insert statement.
INSERT
insert into empt (loc,country,mob)
values ('&loc','&country',&mob)
Hope you need Update.
UPDATE
Update empt
Set loc = '&loc',
country = '&country',
mob = &mob
where address='COB';
Please refer SQL Statements used in oracle
https://docs.oracle.com/database/121/TDDDG/tdddg_dml.htm#TDDDG23100
Upvotes: 0
Reputation: 85
This looks like you may need to use update
if the field already exists in your table -
i.e.
update empt
set loc =?, country = ?, mob=?
where address ='COB';
Upvotes: 1