Results 1 to 8 of 8

Thread: Insert values to tables in SQL

  1. #1
    Join Date
    May 2009
    Posts
    15

    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 :

    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 ??

  2. #2
    Join Date
    May 2009
    Posts
    1

    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:
    UPDATE table_name
    SET column1=value, column2=value2,...
    WHERE some_column=some_value
    In your case.

    UPDATE EMPLOYEE
    SET USERNAME='SALEM', PASSWORD='123456'
    WHERE ECPR='7710234'
    I hope this helps.
    Since I am also learning SQL.

  3. #3
    Join Date
    Mar 2008
    Posts
    227

    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.

  4. #4
    Join Date
    May 2009
    Posts
    15

    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 = ........) .

  5. #5
    Join Date
    Mar 2008
    Posts
    227

    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.

  6. #6
    Join Date
    May 2009
    Posts
    15

    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 :'(

  7. #7
    Join Date
    May 2009
    Posts
    15

    Re: Insert values to tables in SQL



    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

  8. #8
    Join Date
    Mar 2008
    Posts
    227

    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.

Similar Threads

  1. W32 registry values are not getting matched by the default values
    By Angrzej in forum Networking & Security
    Replies: 5
    Last Post: 19-05-2011, 12:23 PM
  2. VPN and routing tables
    By Allison in forum Networking & Security
    Replies: 4
    Last Post: 25-11-2010, 01:02 AM
  3. How to use Tables in Java?
    By Rob Dizzle in forum Software Development
    Replies: 4
    Last Post: 11-02-2010, 07:04 AM
  4. Subtraction between two SQL tables
    By KADRI in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 05:49 PM
  5. SQL - Update via 2 Tables
    By Bantu in forum Software Development
    Replies: 3
    Last Post: 19-01-2009, 08:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,009,936.99766 seconds with 16 queries