Friday, March 30, 2012

mapping two references from one table ?

Hi, I'm new to SQL programming and SQL 2000 server.
My problem is that I have a table that contains antenna information.
(Their can be different types of antenna's)
I have another table that points to the antenna table twice, because it
needs two different types of antennas. IE: GPS and radio
When I try to map the results, I don't know how to specify which one I
want to reference.
For example: This is what the query builder builds for me
SELECT DrtType.TxAntennaId, DrtType.GpsAntennaId, Antenna.AntennaId,
Antenna.AntennaName FROM DrtType INNER JOIN Antenna ON
DrtType.TxAntennaId = Antenna.AntennaId AND DrtType.GpsAntennaId =
Antenna.AntennaId
When I try to format the datagrid. I need to map each value that I use
individually
//// Add GPS Antenna
DataGridColumnStyle TextCol_3 = new DataGridTextBoxColumn();
TextCol_3.MappingName = "AntennaName";
TextCol_3.HeaderText = "Gps Antenna";
TextCol_3.Width = defaultWidth;
dgStyle.GridColumnStyles.Add(TextCol_3);
But I only have one AntennaName to map.
Can I do something like:
DrtType.TxAntennaId.AntennaName
DrtType.GpsAntennaId.AntennaName
Thank you for you helpOn 29 Nov 2005 18:11:07 -0800, oracle wrote:

>Hi, I'm new to SQL programming and SQL 2000 server.
>My problem is that I have a table that contains antenna information.
>(Their can be different types of antenna's)
>I have another table that points to the antenna table twice, because it
>needs two different types of antennas. IE: GPS and radio
>When I try to map the results, I don't know how to specify which one I
>want to reference.
>For example: This is what the query builder builds for me
>SELECT DrtType.TxAntennaId, DrtType.GpsAntennaId, Antenna.AntennaId,
>Antenna.AntennaName FROM DrtType INNER JOIN Antenna ON
>DrtType.TxAntennaId = Antenna.AntennaId AND DrtType.GpsAntennaId =
>Antenna.AntennaId
Hi oracle,
You have to join the Antenna table twice, and use aliases to
distinguishe between the two:
SELECT D.TxAntennaId, D.GpsAntennaId,
TX.AntennaName AS TX_Antenna,
GPS.AntennaName AS GPS_Antenna
FROM DrtType AS D
INNER JOIN Antenna AS TX
ON TX.AntennaId = D.TxAntennaId
INNER JOIN Antenna AS GPS
ON GPS = D.GpsAntennaId
(untested - see www.aspfaq.com/5006 if you prefer a tested reply)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)sql

No comments:

Post a Comment