September 26, 2005 at 12:10 pm
Trying to do the following for general purposes, here's the specifics:
Two Tables: (Person, Address)
Person: Person_ID, First_NM and Last_NM
Address: Address_ID, Person_Id (Unique identifier) and Address_Text
Two Parameters: (@First_NM, @Last_NM)
Need to return the address text by querying a person _id linked to the the person name.
TIA
September 26, 2005 at 12:18 pm
Can't work, names are repeatable so you might have 2 John Smith>>returning 2 ids.
In what context would you want to do that?
September 26, 2005 at 12:21 pm
Just an example that I need to put together, but not in actual development, here is what I have so far.
CREATE PROCEDURE sp_findaddress
@LAST_NM varchar(25),
@FIRST_NM varchar(25),
AS
SELECT @LAST_NAME, @FIRST_NM FROM PERSON
WHERE @LAST_NM, @FIRST_NM=PERSON_ID
I'm not sure how to go about querying the ADDRESS table from here??
September 26, 2005 at 12:26 pm
Seems too much like an homework question...
This is just a simple inner join, there's no way a programmer can't figure this one out.
September 26, 2005 at 1:14 pm
Anyone else?
September 26, 2005 at 1:19 pm
September 26, 2005 at 1:51 pm
Thanks RGR,
Here's what I have now:
CREATE PROCEDURE sp_findaddress
@LAST_NM varchar(25),
@FIRST_NM varchar(25),
AS
SELECT PERSON.LAST_NM AND FIRST_NM, ADDRESS.PERSON_ID
FROM PERSON, ADDRESS
WHERE PERSON.EMPLOYEE_ID=ADDRESS.ADDR.TEXT
September 26, 2005 at 2:03 pm
This is probably closer:
SELECT PERSON.LAST_NM, PERSON.FIRST_NM, ADDRESS.ADDR_TEXT
FROM PERSON, ADDRESS
WHERE PERSON.EMPLOYEE_ID=ADDRESS.PERSON_ID
September 26, 2005 at 2:03 pm
SELECT PERSON.LAST_NM, FIRST_NM, ADDRESS.Text
FROM PERSON INNER JOIN ADDRESS
ON PERSON.EMPLOYEE_ID=ADDRESS.EMPLOYEE_ID
where PERSON.LAST_NM = @LAST_NM AND FIRST_NM = @FIRST_NM
September 27, 2005 at 9:49 am
hehehe...definitely looks like a homework question. You'll have to buy all these okes a beer if you pass Sasha.
September 27, 2005 at 9:54 am
haha, unfortunately didn't pass, but give's me a better understanding of how these things work.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply