August 14, 2006 at 10:24 am
Table A: contains a field "Name" and another field "Name2". The data types for these fields are ints.
Table B: contains two fields: "NameID" and "ActualName".
The fields "Name" and "Name2" from Table A need to match up with the "ActualName" from Table B.
I need to create a view that has fields "Name1" and "Name2" that contain the value of the "ActualName" field in Table B.
Any help would be appreciated.
August 14, 2006 at 10:40 am
a union query in the view should work
select ActualName from TableA t1, TableB t2
where t2.nameID = t1.Name
union
select ActualName from tableA t1, TableB t2
where t2.nameID = t1.Name2
August 14, 2006 at 11:03 am
Would it be possible to obtain this data as one record, rather than 2 which is the case currently?
August 15, 2006 at 5:16 am
are nameid and actualname ints too?
and anything is possible... but need more info to give you a solution...
is their a common column, like do is theredo name and nameid match? is name2 and actualname the same, just different column names?
August 15, 2006 at 5:22 am
if i re-read what you asked for right, here is one possible solution:
SELECT a.Name, b.ActualName [Name_Actual], b.NameID [Name_ID],
a.name2, c.ActualName [Name2_Actual], c.NameID [Name2_ID]
FROM TableA a
LEFT JOIN TableB b
ON a.name = b.ActualName
LEFT JOIN TableB c
ON a.name2 = c.ActualName
August 15, 2006 at 5:23 am
Try
August 15, 2006 at 6:58 am
I actually figured it out. Actual name is a string in table B. Name1 and Name2 are ints in table A that referred to NameID in table B.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply