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 |
|
lriccio
Starting Member
2 Posts |
Posted - 2007-02-01 : 16:01:21
|
| Hi all,first of all, sorry for my english! i'm swiss and i don't speak english very well.i have a problem with a "difficult" query, for me...i will explain my problem :i have 4 tables : Phone_List (phone_list_id, name)Phone_number (phone_number_id, phone, label)phone_list_member (phone_list_id, phone_number_id)temp (name, phone)Here is a example :Phone_List______________________phone_list_id | name |______________________2 | Bank |3 | Shop |5 | My company |Phone_number_id___________________________________phone_number_id | phone | label |___________________________________1 | 1234 | Joey |2 | 4032 | Luis |3 | 3067 | John |4 | 6209 | Maggie |5 | 4900 | Romeo |6 | 4901 | Denis |Phone_List_member_________________________________phone_list_id | phone_number_id |_________________________________2 | 1 |3 | 5 |Temp_________________________________name | phone |_________________________________ Mario | 6038 | Jens | 6094 | Joey | 1234 | Romeo | 4902 | Bill | 6209 |My problem is that i would like to update the phone_number table which the table who contains the phone number of my company. The temp table is the up-to-date phone directory of my company. The problem is, that the phone_number table conatins all our phone_number (even the other phone number, not only our company).I still found the queries to :- insert the new people- delete the people who left the companyBut i don't found how to update the ones to change his/her phone number or when the people has changed her/his name.The problem is the reference table (phone_list_member). I would like to say "select the personne who have the phone_list_id number 5 and who are changed her name or her phone number..."I don't know what i have to do...If someone can help me please... |
|
|
MohammedU
Posting Yak Master
145 Posts |
Posted - 2007-02-01 : 18:27:45
|
| Try the following...Update pnset pn.phone = t.phone from Phone_number_id pnjoin Temp t on t.name = pn.labeljoin phone_list_member pm on pm.phone_number_id = pn.phone_number_id join phone_list pl on pl.phone_list_id = pm.phone_list_id where pl.name = 'my company'MohammedU |
 |
|
|
lriccio
Starting Member
2 Posts |
Posted - 2007-02-02 : 16:56:19
|
| I think it's working!!!Thank you very much!! |
 |
|
|
|
|
|