Insert values to tables in SQL
i had do a table and insert all values in it ..
after that i had alter it and add 2 new columns ( username, password)
now i am trying to add values to these coulmns..
but for each emplouee saparedly..
i mean .. as example :
emp1= CPR: 85236941 , name: salem , phone:123456
i want to insert for him a ( username, password)
i tried :
Quote:
INSERT INTO EMPLOYEE (USERNAME,PASSWORD)
VALUES ('SALEM','123456')
WHERE ECPR= '77102345';
but it was wrong and SQL siad:
ORA-00933: SQL command not properly ended
what to do ??
Re: Insert values to tables in SQL
Hi,
You have altered the table already.
Now you want to add the information for record Username & password for a particular record in a table.
For this you need to fire an update query & not the insert query.
SQL UPDATE Syntax:
Quote:
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
In your case.
Quote:
UPDATE EMPLOYEE
SET USERNAME='SALEM', PASSWORD='123456'
WHERE ECPR='7710234'
I hope this helps.
Since I am also learning SQL.
Re: Insert values to tables in SQL
General format to insert the values in the SQL Table is to INSERT INTO
Code:
Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999')
even you have also used the proper convention to use in your program but the only problem which i sees on top is that for the password value also you have inserted single quote which is not required for numbers, try removing quote and try to run the program again.
Re: Insert values to tables in SQL
thax alot bro.NoelDressy..
i had not check it yet.. cause i leave uni. ,, but a think it is a good Suggestion i will check it later.
bro. DIID ..
i tried to but it with and without the single qutes .. and it still refuse entering it .. and the real problem is to insert new values to new columns for a spacific record that had ( CPR = ........) .
Re: Insert values to tables in SQL
What all other programs similar to the mentioned above have you tried, have they worked properly? or have the same problem if this is the problem then you need to start it from the scratch, or else you just post here all the program steps and let me check out. :thumbup1:
Re: Insert values to tables in SQL
Hi,
bro. i had check this one:
SQL> UPDATE EMPLOYEE
2 SET USERNAME='SALEM',PASSWORD='123456'
3 WHERE ECPR='7710234';
0 rows updated.
and as you can see nothing had updated !!
bro. DIID ,,
i will put my program to you:
CREATE TABLE EMPLOYEE
(ECPR number(9),
NAME VARCHAR2(15),
ADDR VARCHAR2(40) ,
PHONE VARCHAR2(9),
TYPE CHAR(1),
username varchar2(15),
password varchar2(15),
CONSTRAINT EPK PRIMARY KEY (ECPR)
);
ones in red i had add them after inserting data into table.. now i am trying to add data to these coulmns for each employee saparetly..
INSERT INTO EMPLOYEE VALUES
(77102345, 'SALEM', 'SITRA-BAHRAIN', '55-940467', 'M');
and then try the above code to add and it dose not work too :'(
Re: Insert values to tables in SQL
:whistling
I was putting a wrong CPR NO, so it was not work for me !!
i had do it now.. so thanx alot all of you brothers :wub:
Re: Insert values to tables in SQL
Hi CS,
Sorry to be little bit late, i read your earlier message then the last one, when i see your earlier message in that your program seems to be very perfect,and it should run, then i went for your last message where you have solved your problem. That's nice, It's good that you solved your query by yourself.
Hope you will post your problem next time when you have doubt.:thumbup1: