2
   

sql update statement

 
 
hoachen
 
Reply Sat 2 Apr, 2005 09:30 am
Hello everybody
I have a problem with this sql update statement and couldn't spot what's the problem is, can anyone give me an advice? Your advice is very appreciated
Here is the code:
update Admin SET Admin.username = AdminLogin.username from Admin, AdminLogin WHERE Admin.name = AdminLogin.name;

ERROR
update Admin SET Admin.username = AdminLogin.username
from Admin, AdminLogin WHERE Admin.name = AdminLogin.name ;

from Admin, AdminLogin WHERE Admin.name = AdminLogin.name
*
ERROR at line 2:
ORA-00933: SQL command not properly ended



I have an 'Admin' table and 'AdminLogin' table that look like this
Admin table fields AdminLogin field
Name Username Password Name UserName Password
John smith John Smith jsaa1 js001

in Admin table username and password is blank so I need to update the data from AdminLogin into Admin table. I am not allow to use insert into Admin values....... I have to use update.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 2,219 • Replies: 4
No top replies

 
nighthawk
 
  1  
Reply Sat 2 Apr, 2005 03:36 pm
you dont use the "from" keyword in an update statement. Try the following:

Code:
update Admin SET Admin.username = AdminLogin.username WHERE Admin.name = AdminLogin.name;
0 Replies
 
hoachen
 
  1  
Reply Sun 3 Apr, 2005 11:30 am
SQL> update Admin SET Admin.username = AdminLogin1.username WHERE Admin.name = AdminLogin.name;
WHERE Admin.name = AdminLogin.name
*
ERROR at line 2:
ORA-00904: "AdminLOGIN"."NAME": invalid identifier

do you think this is because of table creation has problem?

create table AdminLogin(
name varchar2(25),
username varchar2(20),
password varchar2(20),
primary key (name),
foreign key (name) references Admin);

create table Admin (
name varchar2(20),
username varchar2(20),
password varchar2(20),
address varchar2(40),
salary real,
phone varchar2(12),
primary key (name));
0 Replies
 
nighthawk
 
  1  
Reply Mon 4 Apr, 2005 05:17 pm
sorry the code i gave you forgot to say that you were updating 2 different tables, try:

Code:
update Admin, AdminLogin SET Admin.username = AdminLogin.username WHERE Admin.name = AdminLogin.name;
0 Replies
 
hoachen
 
  1  
Reply Thu 7 Apr, 2005 03:16 pm
nighthawk wrote:
sorry the code i gave you forgot to say that you were updating 2 different tables, try:

Code:
update Admin, AdminLogin SET Admin.username = AdminLogin.username WHERE Admin.name = AdminLogin.name;
thank you very much for your advice.

Cheer
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » sql update statement
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.06 seconds on 12/22/2024 at 02:13:07