Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return a Name instead of the ID

Status
Not open for further replies.

debbie1212

Programmer
May 31, 2000
66
US
I have an ASP page that needs to display the location name instead of the location ID but I'm using the ID in the table that contains the data.

These are the tables:

Location
LOC_ID
LOC_NAME

Request
REQ_TO_LOC_ID
REQ_FROM_LOC_ID

I need to have it save the ID in the Request table (which it does) but when I retrieve it, I need it to look at the Location table and get the Location Name that corresponds to the Location ID.

Thanks,
Debbie
 
Try something like this:

SQL = "SELECT R.Req_To_Loc_ID, L.LocName "
SQL = SQL & " FROM Request R"
SQL = SQL & " INNER JOIN Location L ON R.Req_to_Loc_ID = L.LocID"

And if you have conditions, just add your WHERE clause on to this. This select will return all of the Req_To_Loc_IDs and their corresponding names.
 
I had the feeling I was going to have to use a JOIN. I'm not real familiar with them. I'll give it a try.

Thanks!!!!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top