Groups | Blog | Home
all groups > sql server programming > september 2003 >

sql server programming : Update Query Help


Lontae Jones
9/22/2003 9:59:25 PM
Hello,

I have a table called Agent which has 2 columns (AgentID
and Phone). My second table is Phone_Numb (AgentID and
Phone) I AgentID's are the same in both tables. I need
to update the Agent table with the Phone numbers in the
David Portas
9/23/2003 11:20:43 AM
What's the Primary Key in the Phone_Number table?

If it's Agentid, then:

UPDATE Agent
SET phone =
(SELECT phone
FROM Phone_Numb
WHERE agentid = Agent.agentid)


If not, do I assume that you just want *any* phone number for the Agentid
(that's what OJ's solution gives you)? If so:

UPDATE Agent
SET phone =
(SELECT MIN(phone)
FROM Phone_Numb
WHERE agentid = Agent.agentid)

--
David Portas
------------
Please reply only to the newsgroup
--

[quoted text, click to view]

AddThis Social Bookmark Button