Page 1 of 1

Update with Select Query

Posted: Wed Mar 03, 2004 3:32 am
by phppick
I have Two tables in my POSTGRES DATABASE,

1. Student
2. Library_Student_Info

I want to Join the two tables and Update the 'Library_Student_Info' table with matched records. I am using the following Query

UPDATE Library_Student_Info SET Name = (
SELECT Name
FROM Student WHERE Student_ID= Library_Student_Info.Student_ID
LIMIT 1);



Anybody Can Help me ???

And also this i tried but Error..

UPDATE Library_Student_Info EM SET Name = (SELECT Name FROM Student DIR WHERE
DIR.Student_ID = EM.Student_ID AND
EM.Student_ID IS NOT NULL)

Posted: Wed Mar 03, 2004 10:49 am
by scorphus
A WHERE clause should be missing:

Code: Select all

UPDATE Library_Student_Info SET Name = (
SELECT Name
FROM Student WHERE Student_ID= Library_Student_Info.Student_ID
LIMIT 1) WHERE Name = '_null' OR <something>;
What is the error message returned by Postgre?

Scorphus.