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.
| Author |
Topic |
|
Sambhav
Starting Member
31 Posts |
Posted - 2007-07-03 : 11:43:51
|
| Hi please help me out !! I have to update the incidents table.The initiator and initdept are two corresponding columns in incidents table whoes value I have to get from another table Employee where (initiator means Empname and initdept means title)if i just do select Empname,title from employee it gives me correct output while select initiator,initdept from incidentsIt gives the initiator correct but instead of giving the initdept it gives output as initaiator The Output is given below initiator initdeptJeff C. Taylor Jeff C. Taylor Randy S. Jonas Randy S. Jonas Mike lewis Mike lewis it should give the out put like initiator initdeptJeff C. Taylor Software Engg Randy S. Jonas TesterI hope you got my question!now I hav to update incidents table such that it should give initiator as well as its corrosponding initdept thanks |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-07-03 : 12:00:20
|
Do you really want to Update incidents table? or just want to display initiator and corresponding department in SELECT statement?Select e.EmpName as Initiator, e.Title as InitDeptFrom Employee e JOIN incidents i on e.pk = i.pk Note: pk indicates key column which is common in both tables, most probably primary key.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
Sambhav
Starting Member
31 Posts |
Posted - 2007-07-03 : 12:35:33
|
I have to update it as I am populating data for testing and the primary key what I think is Empname only because the common field are title and empname ....sambhav jain |
 |
|
|
Sambhav
Starting Member
31 Posts |
Posted - 2007-07-03 : 15:03:27
|
| select is working perfectly fine but how to update the data already in the incidents table .......sambhav jain |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-07-03 : 15:53:32
|
| [code]Update I Set Initiator = E.Empname , Initdept = E.TitleFrom Incidents I Inner Join Employee E On I.Pk = E.Pk[/code]Chiraghttp://chirikworld.blogspot.com/ |
 |
|
|
Sambhav
Starting Member
31 Posts |
Posted - 2007-07-05 : 17:39:05
|
Thanks i got it !! sambhav jain |
 |
|
|
|
|
|