Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Get id

Author  Topic 

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-01-26 : 03:42:40
Hi,

I have two tables

Class Faculty
FacultyID, ClassID FacultyID, BooksID

I want to get all rows of BooksID in class table using FacultyID of faculty table.

Thanks

Navi

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-26 : 04:26:01
[code]SELECT *
FROM Class c INNER JOIN Faculty f
ON c.FacultyID = f.FacultyID[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-01-26 : 04:39:32
Thanks,

I want to get Data of BooksID from "Faculty" compairing FacultyID
there is no name of BooksID.


Navi
Go to Top of Page

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-01-26 : 04:48:45
Hi,

I think I cannot convey my Question.
I want to update Table "Class" column name "BooksID" by comparing Table "Faculty"

"Faculty" have fields name "FacultyID", BooksID,
"Class" have fields name "ClassID" FacultyID, BooksID,(BooksID I just created now therefore there is no data in in the column)
I want to get Data in the BooksID by using FacultyID.


Navi
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-26 : 07:25:26
maybe you can post your table structure, sample data and expected output


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-26 : 08:33:23
quote:
Originally posted by feejaz

Hi,

I think I cannot convey my Question.
I want to update Table "Class" column name "BooksID" by comparing Table "Faculty"

"Faculty" have fields name "FacultyID", BooksID,
"Class" have fields name "ClassID" FacultyID, BooksID,(BooksID I just created now therefore there is no data in in the column)
I want to get Data in the BooksID by using FacultyID.


Navi



UPDATE c
SET c.BooksID=f.BooksID
FROM Class c
INNER JOIN Faculty f
ON f.FacultyID=c.FacultyID
Go to Top of Page

feejaz
Yak Posting Veteran

68 Posts

Posted - 2008-01-28 : 02:08:58
Thanks visakh16,

Thats update mu table. But can u tell me How can we add more rows in the "class" table.
In "class" table every SchoolID have 1 or 2 classID. Whereas in "Faculty" every facultyID have more than 3 SchoolID.

Therefore when I update the table it only update the rows not entering new rows as per schoolID.
Can you tell me how can we add new rows.

Thanks



Navi
Go to Top of Page
   

- Advertisement -