Sign Up |  Live StatsLive Stats    Articles 35,345| Comments 159,788| Members 17,820, Newest waheguruhelpme| Online 221
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

Sikh Philosophy Network » Sikh Philosophy Network » Current Affairs » Information Technology » Building a query to get relevant names for FKs

Building a query to get relevant names for FKs

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 400 USD, Received: 35 USD (9%)
Please Donate...
Related Topics...
Thread Thread Starter Forum Replies Last Post
Relevant Differences Between Islam and Sikhism (English Defense League Blog) Narayanjot Kaur Islam 7 05-Jan-2011 11:40 AM
Building your own house singhbj General Discussion 0 03-Jun-2008 00:38 AM
Query Field Names AND Captions Rowsource for ListBox Debra Farnham Information Technology 2 28-Jul-2006 08:31 AM
Query Field Names from Tables nFaux Information Technology 1 28-Jul-2006 08:11 AM
Help with building an access database. Bec Information Technology 5 15-Nov-2005 14:11 PM


Tags
building, query, relevant, names, fks
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:03 AM
Lisa's Avatar Lisa
Guest
 
Posts: n/a
   
   
Building a query to get relevant names for FKs

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi,

I have a question regarding building a query to get a relevant name for a
foreign key.

My database structure is as follows:

Table:ConfigOptions
ID
Name
Location

Tableependencies
ID
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/9538-building-query-get-relevant-names-fks.html
ConfigOptionID
DependencyID

Table:Location
ID
LocationDescription

What I need to do is build a query that returns ConfigOption Name,
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
ConfigOption Location, Dependency Name, Dependency Location

Using the following query, I can get the real name for ConfigOption Name,
ConfigOption Location, and Dependency Name, but only the FK value for
Dependency Location.

SELECT StaticConfigOptions.parameterName AS Parameter,
StaticConfigOptions.parameterLocation,
(select StaticConfigOptions.parameterName from StaticConfigOptions where
StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
(select StaticConfigOptions.parameterLocation from StaticConfigOptions
WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
DependencyLocationID
FROM StaticConfigOptions INNER JOIN Dependencies ON
StaticConfigOptions.parameterID=Dependencies.param eterID;

How do I get the real name (located in the parameterLocation table under
LocationDescription) to appear?

Whatever I try to do seems to crash Access.

Thank you!!






 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:03 AM
Michael H's Avatar Michael H
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

Lisa,

Have you described the table structure correctly? I'm not sure why the
Dependencies table would have a DependencyID field. Is that field actually
located in the Location table?

By the way, it is not a good idea to have a field called "Name". That is a
reserved word in Access. A better field name would be something like
"OptionName".

-Michael


"Lisa" wrote:

> Hi,
>
> I have a question regarding building a query to get a relevant name for a
> foreign key.
>
> My database structure is as follows:
>
> Table:ConfigOptions
> ID
> Name
> Location
>
> Tableependencies
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> ID
> ConfigOptionID
> DependencyID
>
> Table:Location
> ID
> LocationDescription
>
> What I need to do is build a query that returns ConfigOption Name,
> ConfigOption Location, Dependency Name, Dependency Location
>
> Using the following query, I can get the real name for ConfigOption Name,
> ConfigOption Location, and Dependency Name, but only the FK value for
> Dependency Location.
>
> SELECT StaticConfigOptions.parameterName AS Parameter,
> StaticConfigOptions.parameterLocation,
> (select StaticConfigOptions.parameterName from StaticConfigOptions where
> StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> DependencyLocationID
> FROM StaticConfigOptions INNER JOIN Dependencies ON
> StaticConfigOptions.parameterID=Dependencies.param eterID;
>
> How do I get the real name (located in the parameterLocation table under
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> LocationDescription) to appear?
>
> Whatever I try to do seems to crash Access.
>
> Thank you!!
>

Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:03 AM
KARL DEWEY's Avatar KARL DEWEY
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

I hard a hard time on this one as your table and field names do not match
those in the SQL. Also your SQL just would not fly as posted but I think I
figured out what you wanted. Try the SQL below and add or remove display
fields as you wish.

SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
Location_1.LocationDescription AS [Dependent Location]
FROM (StaticConfigOptions LEFT JOIN Location ON
StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538


"Lisa" wrote:

> Hi,
>
> I have a question regarding building a query to get a relevant name for a
> foreign key.
>
> My database structure is as follows:
>
> Table:ConfigOptions
> ID
> Name
> Location
>
> Tableependencies
> ID
> ConfigOptionID
> DependencyID
>
> Table:Location
> ID
> LocationDescription
>
> What I need to do is build a query that returns ConfigOption Name,
> ConfigOption Location, Dependency Name, Dependency Location
>
> Using the following query, I can get the real name for ConfigOption Name,
> ConfigOption Location, and Dependency Name, but only the FK value for
> Dependency Location.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
>
> SELECT StaticConfigOptions.parameterName AS Parameter,
> StaticConfigOptions.parameterLocation,
> (select StaticConfigOptions.parameterName from StaticConfigOptions where
> StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> DependencyLocationID
> FROM StaticConfigOptions INNER JOIN Dependencies ON
> StaticConfigOptions.parameterID=Dependencies.param eterID;
>
> How do I get the real name (located in the parameterLocation table under
> LocationDescription) to appear?
>
> Whatever I try to do seems to crash Access.
>
> Thank you!!
>

Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:03 AM
Lisa's Avatar Lisa
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

Hi Karl,

It didn't quite work for what is needed. Let me try and explain it a little
more (I'll the true table names -- I thought real table names would be
cumbersome, but I guess the opposite was true in this case, sorry)

Table: StaticConfigOptions
parameterID
parameterName
parameterLocation
....

Table: ParameterLocation
parameterLocationID
parameterLocationDescription
....

Table: Dependencies
dependencyID
parameterID
dependency

(the dependency table is a table with a primary key, dependencyID, and two
foreign keys, both from the parameterID field from the StaticConfigOptions
table)

The Dependencies table is linked to the StaticConfigOptions table and the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
StaticConfigOptions table is also linked to the ParameterLocation table.

So far I can get a query that tells me the Parameter Name, the Location, and
the Dependency. What I'm missing is the Dependency Location. I can get the
numerical value, but not that elusive parameterLocationDescription.

Thank you very much for all your help!

"KARL DEWEY" wrote:

> I hard a hard time on this one as your table and field names do not match
> those in the SQL. Also your SQL just would not fly as posted but I think I
> figured out what you wanted. Try the SQL below and add or remove display
> fields as you wish.
>
> SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> Location_1.LocationDescription AS [Dependent Location]
> FROM (StaticConfigOptions LEFT JOIN Location ON
> StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
>
>
> "Lisa" wrote:
>
> > Hi,
> >
> > I have a question regarding building a query to get a relevant name for a
> > foreign key.
> >
> > My database structure is as follows:
> >
> > Table:ConfigOptions
> > ID
> > Name
> > Location
> >
> > Tableependencies
> > ID
> > ConfigOptionID
> > DependencyID
> >
> > Table:Location
> > ID
> > LocationDescription
> >
> > What I need to do is build a query that returns ConfigOption Name,
> > ConfigOption Location, Dependency Name, Dependency Location
> >
> > Using the following query, I can get the real name for ConfigOption Name,
> > ConfigOption Location, and Dependency Name, but only the FK value for
> > Dependency Location.
> >
> > SELECT StaticConfigOptions.parameterName AS Parameter,
> > StaticConfigOptions.parameterLocation,
> > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > DependencyLocationID
> > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > StaticConfigOptions.parameterID=Dependencies.param eterID;
> >
> > How do I get the real name (located in the parameterLocation table under
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > LocationDescription) to appear?
> >
> > Whatever I try to do seems to crash Access.
> >
> > Thank you!!
> >

Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:03 AM
KARL DEWEY's Avatar KARL DEWEY
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

Try this --
SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
ParameterLocation.parameterLocationDescription,
ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
StaticConfigOptions.parameterLOCATION =
ParameterLocation.parameterLocationID) LEFT JOIN Dependencies ON
StaticConfigOptions.parameterID = Dependencies.parameterID) LEFT JOIN
ParameterLocation AS ParameterLocation_1 ON Dependencies.DependencyID =
ParameterLocation_1.parameterLocationID;


"Lisa" wrote:

> Hi Karl,
>
> It didn't quite work for what is needed. Let me try and explain it a little
> more (I'll the true table names -- I thought real table names would be
> cumbersome, but I guess the opposite was true in this case, sorry)
>
> Table: StaticConfigOptions
> parameterID
> parameterName
> parameterLocation
> ...
>
> Table: ParameterLocation
> parameterLocationID
> parameterLocationDescription
> ...
>
> Table: Dependencies
> dependencyID
> parameterID
> dependency
>
> (the dependency table is a table with a primary key, dependencyID, and two
> foreign keys, both from the parameterID field from the StaticConfigOptions
> table)
>
> The Dependencies table is linked to the StaticConfigOptions table and the
> StaticConfigOptions table is also linked to the ParameterLocation table.
>
> So far I can get a query that tells me the Parameter Name, the Location, and
> the Dependency. What I'm missing is the Dependency Location. I can get the
> numerical value, but not that elusive parameterLocationDescription.
>
> Thank you very much for all your help!
>
> "KARL DEWEY" wrote:
>
> > I hard a hard time on this one as your table and field names do not match
> > those in the SQL. Also your SQL just would not fly as posted but I think I
> > figured out what you wanted. Try the SQL below and add or remove display
> > fields as you wish.
> >
> > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> > Location_1.LocationDescription AS [Dependent Location]
> > FROM (StaticConfigOptions LEFT JOIN Location ON
> > StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> > LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> > Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
> >
> >
> > "Lisa" wrote:
> >
> > > Hi,
> > >
> > > I have a question regarding building a query to get a relevant name for a
> > > foreign key.
> > >
> > > My database structure is as follows:
> > >
> > > Table:ConfigOptions
> > > ID
> > > Name
> > > Location
> > >
> > > Tableependencies
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > > ID
> > > ConfigOptionID
> > > DependencyID
> > >
> > > Table:Location
> > > ID
> > > LocationDescription
> > >
> > > What I need to do is build a query that returns ConfigOption Name,
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > > ConfigOption Location, Dependency Name, Dependency Location
> > >
> > > Using the following query, I can get the real name for ConfigOption Name,
> > > ConfigOption Location, and Dependency Name, but only the FK value for
> > > Dependency Location.
> > >
> > > SELECT StaticConfigOptions.parameterName AS Parameter,
> > > StaticConfigOptions.parameterLocation,
> > > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > > DependencyLocationID
> > > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > > StaticConfigOptions.parameterID=Dependencies.param eterID;
> > >
> > > How do I get the real name (located in the parameterLocation table under
> > > LocationDescription) to appear?
> > >
> > > Whatever I try to do seems to crash Access.
> > >
> > > Thank you!!
> > >

Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:03 AM
Lisa's Avatar Lisa
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

It's still not returning the dependency location properly. :-( What it does
is returns the parameterID and parameterName from StaticConfig options
regardless of whether it has a dependency. The dependencyLocation column
shows up, but it isn't displaying the proper table locations (but they're
names, not numbers, so we're closer!), nor a column that shows the actual
dependency parameter names. I added the dependency column to your sql below,
but the location of those dependencies are not correct.

Thank you for your continued help on this!!

SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
ParameterLocation.parameterLocationDescription, (select
StaticConfigOptions.parameterName from StaticConfigOptions where
StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
StaticConfigOptions.parameterLOCATION=ParameterLoc ation.parameterLocationID)
LEFT JOIN Dependencies ON
StaticConfigOptions.parameterID=Dependencies.param eterID) LEFT JOIN
ParameterLocation AS ParameterLocation_1 ON
Dependencies.DependencyID=ParameterLocation_1.para meterLocationID;




"KARL DEWEY" wrote:

> Try this --
> SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> ParameterLocation.parameterLocationDescription,
> ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> StaticConfigOptions.parameterLOCATION =
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> ParameterLocation.parameterLocationID) LEFT JOIN Dependencies ON
> StaticConfigOptions.parameterID = Dependencies.parameterID) LEFT JOIN
> ParameterLocation AS ParameterLocation_1 ON Dependencies.DependencyID =
> ParameterLocation_1.parameterLocationID;
>
>
> "Lisa" wrote:
>
> > Hi Karl,
> >
> > It didn't quite work for what is needed. Let me try and explain it a little
> > more (I'll the true table names -- I thought real table names would be
> > cumbersome, but I guess the opposite was true in this case, sorry)
> >
> > Table: StaticConfigOptions
> > parameterID
> > parameterName
> > parameterLocation
> > ...
> >
> > Table: ParameterLocation
> > parameterLocationID
> > parameterLocationDescription
> > ...
> >
> > Table: Dependencies
> > dependencyID
> > parameterID
> > dependency
> >
> > (the dependency table is a table with a primary key, dependencyID, and two
> > foreign keys, both from the parameterID field from the StaticConfigOptions
> > table)
> >
> > The Dependencies table is linked to the StaticConfigOptions table and the
> > StaticConfigOptions table is also linked to the ParameterLocation table.
> >
> > So far I can get a query that tells me the Parameter Name, the Location, and
> > the Dependency. What I'm missing is the Dependency Location. I can get the
> > numerical value, but not that elusive parameterLocationDescription.
> >
> > Thank you very much for all your help!
> >
> > "KARL DEWEY" wrote:
> >
> > > I hard a hard time on this one as your table and field names do not match
> > > those in the SQL. Also your SQL just would not fly as posted but I think I
> > > figured out what you wanted. Try the SQL below and add or remove display
> > > fields as you wish.
> > >
> > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> > > Location_1.LocationDescription AS [Dependent Location]
> > > FROM (StaticConfigOptions LEFT JOIN Location ON
> > > StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> > > LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> > > Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
> > >
> > >
> > > "Lisa" wrote:
> > >
> > > > Hi,
> > > >
> > > > I have a question regarding building a query to get a relevant name for a
> > > > foreign key.
> > > >
> > > > My database structure is as follows:
> > > >
> > > > Table:ConfigOptions
> > > > ID
> > > > Name
> > > > Location
> > > >
> > > > Tableependencies
> > > > ID
> > > > ConfigOptionID
> > > > DependencyID
> > > >
> > > > Table:Location
> > > > ID
> > > > LocationDescription
> > > >
> > > > What I need to do is build a query that returns ConfigOption Name,
> > > > ConfigOption Location, Dependency Name, Dependency Location
> > > >
> > > > Using the following query, I can get the real name for ConfigOption Name,
> > > > ConfigOption Location, and Dependency Name, but only the FK value for
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > > > Dependency Location.
> > > >
> > > > SELECT StaticConfigOptions.parameterName AS Parameter,
> > > > StaticConfigOptions.parameterLocation,
> > > > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > > > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > > > DependencyLocationID
> > > > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > > > StaticConfigOptions.parameterID=Dependencies.param eterID;
> > > >
> > > > How do I get the real name (located in the parameterLocation table under
> > > > LocationDescription) to appear?
> > > >
> > > > Whatever I try to do seems to crash Access.
> > > >
> > > > Thank you!!
> > > >

Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:03 AM
KARL DEWEY's Avatar KARL DEWEY
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

I can not follow the changes you made in the SQL.

The way I see your Dependencies table is like a junction table and would
only need two field. Maybe you are showing who is dependent on what and
including a name of the dependancy. Like Mr. Brown - Father-Child - Billy.

Maybe post some data from each table.

"Lisa" wrote:

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> It's still not returning the dependency location properly. :-( What it does
> is returns the parameterID and parameterName from StaticConfig options
> regardless of whether it has a dependency. The dependencyLocation column
> shows up, but it isn't displaying the proper table locations (but they're
> names, not numbers, so we're closer!), nor a column that shows the actual
> dependency parameter names. I added the dependency column to your sql below,
> but the location of those dependencies are not correct.
>
> Thank you for your continued help on this!!
>
> SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> ParameterLocation.parameterLocationDescription, (select
> StaticConfigOptions.parameterName from StaticConfigOptions where
> StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> StaticConfigOptions.parameterLOCATION=ParameterLoc ation.parameterLocationID)
> LEFT JOIN Dependencies ON
> StaticConfigOptions.parameterID=Dependencies.param eterID) LEFT JOIN
> ParameterLocation AS ParameterLocation_1 ON
> Dependencies.DependencyID=ParameterLocation_1.para meterLocationID;
>
>
>
>
> "KARL DEWEY" wrote:
>
> > Try this --
> > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > ParameterLocation.parameterLocationDescription,
> > ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> > FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> > StaticConfigOptions.parameterLOCATION =
> > ParameterLocation.parameterLocationID) LEFT JOIN Dependencies ON
> > StaticConfigOptions.parameterID = Dependencies.parameterID) LEFT JOIN
> > ParameterLocation AS ParameterLocation_1 ON Dependencies.DependencyID =
> > ParameterLocation_1.parameterLocationID;
> >
> >
> > "Lisa" wrote:
> >
> > > Hi Karl,
> > >
> > > It didn't quite work for what is needed. Let me try and explain it a little
> > > more (I'll the true table names -- I thought real table names would be
> > > cumbersome, but I guess the opposite was true in this case, sorry)
> > >
> > > Table: StaticConfigOptions
> > > parameterID
> > > parameterName
> > > parameterLocation
> > > ...
> > >
> > > Table: ParameterLocation
> > > parameterLocationID
> > > parameterLocationDescription
> > > ...
> > >
> > > Table: Dependencies
> > > dependencyID
> > > parameterID
> > > dependency
> > >
> > > (the dependency table is a table with a primary key, dependencyID, and two
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > > foreign keys, both from the parameterID field from the StaticConfigOptions
> > > table)
> > >
> > > The Dependencies table is linked to the StaticConfigOptions table and the
> > > StaticConfigOptions table is also linked to the ParameterLocation table.
> > >
> > > So far I can get a query that tells me the Parameter Name, the Location, and
> > > the Dependency. What I'm missing is the Dependency Location. I can get the
> > > numerical value, but not that elusive parameterLocationDescription.
> > >
> > > Thank you very much for all your help!
> > >
> > > "KARL DEWEY" wrote:
> > >
> > > > I hard a hard time on this one as your table and field names do not match
> > > > those in the SQL. Also your SQL just would not fly as posted but I think I
> > > > figured out what you wanted. Try the SQL below and add or remove display
> > > > fields as you wish.
> > > >
> > > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > > StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> > > > Location_1.LocationDescription AS [Dependent Location]
> > > > FROM (StaticConfigOptions LEFT JOIN Location ON
> > > > StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> > > > LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> > > > Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
> > > >
> > > >
> > > > "Lisa" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I have a question regarding building a query to get a relevant name for a
> > > > > foreign key.
> > > > >
> > > > > My database structure is as follows:
> > > > >
> > > > > Table:ConfigOptions
> > > > > ID
> > > > > Name
> > > > > Location
> > > > >
> > > > > Tableependencies
> > > > > ID
> > > > > ConfigOptionID
> > > > > DependencyID
> > > > >
> > > > > Table:Location
> > > > > ID
> > > > > LocationDescription
> > > > >
> > > > > What I need to do is build a query that returns ConfigOption Name,
> > > > > ConfigOption Location, Dependency Name, Dependency Location
> > > > >
> > > > > Using the following query, I can get the real name for ConfigOption Name,
> > > > > ConfigOption Location, and Dependency Name, but only the FK value for
> > > > > Dependency Location.
> > > > >
> > > > > SELECT StaticConfigOptions.parameterName AS Parameter,
> > > > > StaticConfigOptions.parameterLocation,
> > > > > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > > > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > > > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > > > > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > > > > DependencyLocationID
> > > > > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > > > > StaticConfigOptions.parameterID=Dependencies.param eterID;
> > > > >
> > > > > How do I get the real name (located in the parameterLocation table under
> > > > > LocationDescription) to appear?
> > > > >
> > > > > Whatever I try to do seems to crash Access.
> > > > >
> > > > > Thank you!!
> > > > >

Reply With Quote
  #8 (permalink)  
Old 28-Jul-2006, 08:03 AM
Lisa's Avatar Lisa
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

Okay, great idea. Here's some sample data:

StaticConfigOption
parameterID parameterName parameterLocation
1 Feet 3
2 Socks 2
3 Shoes 1
4 Shoelaces 1

Dependencies
dependencyID parameterID Dependency
1 2 1
2 3 1
3 3 4
4 4 3

This is saying that socks are dependent on feet, shoes are dependent on feet
and shoelaces, and shoelaces are dependent on shoes.

ParameterLocation
parameterLocationID parameterLocationDescription
1 Closet
2 Laundry Basket
3 Legs

So I want a query that would return the following:

ParameterName ParameterLocation Dependency DependencyLocation
Socks Laundry Basket Feet Legs
Shoes Closet Feet Legs
Shoes Closet Shoelaces Closet
Shoelaces Closet Shoes Closet

Phew! I hope that makes sense. I can't use real data because it's for work,
but that data covers the conditions that I have in my data. Thank you!!

"KARL DEWEY" wrote:

> I can not follow the changes you made in the SQL.
>
> The way I see your Dependencies table is like a junction table and would
> only need two field. Maybe you are showing who is dependent on what and
> including a name of the dependancy. Like Mr. Brown - Father-Child - Billy.
>
> Maybe post some data from each table.
>
> "Lisa" wrote:
>
> > It's still not returning the dependency location properly. :-( What it does
> > is returns the parameterID and parameterName from StaticConfig options
> > regardless of whether it has a dependency. The dependencyLocation column
> > shows up, but it isn't displaying the proper table locations (but they're
> > names, not numbers, so we're closer!), nor a column that shows the actual
> > dependency parameter names. I added the dependency column to your sql below,
> > but the location of those dependencies are not correct.
> >
> > Thank you for your continued help on this!!
> >
> > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > ParameterLocation.parameterLocationDescription, (select
> > StaticConfigOptions.parameterName from StaticConfigOptions where
> > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> > StaticConfigOptions.parameterLOCATION=ParameterLoc ation.parameterLocationID)
> > LEFT JOIN Dependencies ON
> > StaticConfigOptions.parameterID=Dependencies.param eterID) LEFT JOIN
> > ParameterLocation AS ParameterLocation_1 ON
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > Dependencies.DependencyID=ParameterLocation_1.para meterLocationID;
> >
> >
> >
> >
> > "KARL DEWEY" wrote:
> >
> > > Try this --
> > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > ParameterLocation.parameterLocationDescription,
> > > ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> > > FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> > > StaticConfigOptions.parameterLOCATION =
> > > ParameterLocation.parameterLocationID) LEFT JOIN Dependencies ON
> > > StaticConfigOptions.parameterID = Dependencies.parameterID) LEFT JOIN
> > > ParameterLocation AS ParameterLocation_1 ON Dependencies.DependencyID =
> > > ParameterLocation_1.parameterLocationID;
> > >
> > >
> > > "Lisa" wrote:
> > >
> > > > Hi Karl,
> > > >
> > > > It didn't quite work for what is needed. Let me try and explain it a little
> > > > more (I'll the true table names -- I thought real table names would be
> > > > cumbersome, but I guess the opposite was true in this case, sorry)
> > > >
> > > > Table: StaticConfigOptions
> > > > parameterID
> > > > parameterName
> > > > parameterLocation
> > > > ...
> > > >
> > > > Table: ParameterLocation
> > > > parameterLocationID
> > > > parameterLocationDescription
> > > > ...
> > > >
> > > > Table: Dependencies
> > > > dependencyID
> > > > parameterID
> > > > dependency
> > > >
> > > > (the dependency table is a table with a primary key, dependencyID, and two
> > > > foreign keys, both from the parameterID field from the StaticConfigOptions
> > > > table)
> > > >
> > > > The Dependencies table is linked to the StaticConfigOptions table and the
> > > > StaticConfigOptions table is also linked to the ParameterLocation table.
> > > >
> > > > So far I can get a query that tells me the Parameter Name, the Location, and
> > > > the Dependency. What I'm missing is the Dependency Location. I can get the
> > > > numerical value, but not that elusive parameterLocationDescription.
> > > >
> > > > Thank you very much for all your help!
> > > >
> > > > "KARL DEWEY" wrote:
> > > >
> > > > > I hard a hard time on this one as your table and field names do not match
> > > > > those in the SQL. Also your SQL just would not fly as posted but I think I
> > > > > figured out what you wanted. Try the SQL below and add or remove display
> > > > > fields as you wish.
> > > > >
> > > > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > > > StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> > > > > Location_1.LocationDescription AS [Dependent Location]
> > > > > FROM (StaticConfigOptions LEFT JOIN Location ON
> > > > > StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> > > > > LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> > > > > Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
> > > > >
> > > > >
> > > > > "Lisa" wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I have a question regarding building a query to get a relevant name for a
> > > > > > foreign key.
> > > > > >
> > > > > > My database structure is as follows:
> > > > > >
> > > > > > Table:ConfigOptions
> > > > > > ID
> > > > > > Name
> > > > > > Location
> > > > > >
> > > > > > Tableependencies
> > > > > > ID
> > > > > > ConfigOptionID
> > > > > > DependencyID
> > > > > >
> > > > > > Table:Location
> > > > > > ID
> > > > > > LocationDescription
> > > > > >
> > > > > > What I need to do is build a query that returns ConfigOption Name,
> > > > > > ConfigOption Location, Dependency Name, Dependency Location
> > > > > >
> > > > > > Using the following query, I can get the real name for ConfigOption Name,
> > > > > > ConfigOption Location, and Dependency Name, but only the FK value for
> > > > > > Dependency Location.
> > > > > >
> > > > > > SELECT StaticConfigOptions.parameterName AS Parameter,
> > > > > > StaticConfigOptions.parameterLocation,
> > > > > > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > > > > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > > > > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > > > > > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > > > > > DependencyLocationID
> > > > > > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > > > > > StaticConfigOptions.parameterID=Dependencies.param eterID;
> > > > > >
> > > > > > How do I get the real name (located in the parameterLocation table under
> > > > > > LocationDescription) to appear?
> > > > > >
> > > > > > Whatever I try to do seems to crash Access.
> > > > > >
> > > > > > Thank you!!
> > > > > >

Reply With Quote
  #9 (permalink)  
Old 28-Jul-2006, 08:03 AM
Lisa's Avatar Lisa
Guest
 
Posts: n/a
   
   
RE: Building a query to get relevant names for FKs

  Donate Today!  
I got it!

SELECT [StaticConfigOptions].[parameterName] AS Parameter,
[StaticConfigOptions].[parameterLocation], (select
StaticConfigOptions.parameterName from StaticConfigOptions where
StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
(SELECT ParameterLocation.parameterLocationDescription FROM ParameterLocation
where ParameterLocation.parameterLocationID =
(select [StaticConfigOptions].[parameterLocation] from
[StaticConfigOptions] where dependencies.dependency =
[StaticConfigOptions].[parameterID]) ) AS Dependencylocation
FROM StaticConfigOptions INNER JOIN Dependencies ON
[StaticConfigOptions].[parameterID]=[Dependencies].[parameterID];

Thanks for your help on this Karl!!

"Lisa" wrote:

> Okay, great idea. Here's some sample data:
>
> StaticConfigOption
> parameterID parameterName parameterLocation
> 1 Feet 3
> 2 Socks 2
> 3 Shoes 1
> 4 Shoelaces 1
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
>
> Dependencies
> dependencyID parameterID Dependency
> 1 2 1
> 2 3 1
> 3 3 4
> 4 4 3
>
> This is saying that socks are dependent on feet, shoes are dependent on feet
> and shoelaces, and shoelaces are dependent on shoes.
>
> ParameterLocation
> parameterLocationID parameterLocationDescription
> 1 Closet
> 2 Laundry Basket
> 3 Legs
>
> So I want a query that would return the following:
>
> ParameterName ParameterLocation Dependency DependencyLocation
> Socks Laundry Basket Feet Legs
> Shoes Closet Feet Legs
> Shoes Closet Shoelaces Closet
> Shoelaces Closet Shoes Closet
>
> Phew! I hope that makes sense. I can't use real data because it's for work,
> but that data covers the conditions that I have in my data. Thank you!!
>
> "KARL DEWEY" wrote:
>
> > I can not follow the changes you made in the SQL.
> >
> > The way I see your Dependencies table is like a junction table and would
> > only need two field. Maybe you are showing who is dependent on what and
> > including a name of the dependancy. Like Mr. Brown - Father-Child - Billy.
> >
> > Maybe post some data from each table.
> >
> > "Lisa" wrote:
> >
> > > It's still not returning the dependency location properly. :-( What it does
> > > is returns the parameterID and parameterName from StaticConfig options
> > > regardless of whether it has a dependency. The dependencyLocation column
> > > shows up, but it isn't displaying the proper table locations (but they're
> > > names, not numbers, so we're closer!), nor a column that shows the actual
> > > dependency parameter names. I added the dependency column to your sql below,
> > > but the location of those dependencies are not correct.
> > >
> > > Thank you for your continued help on this!!
> > >
> > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > ParameterLocation.parameterLocationDescription, (select
> > > StaticConfigOptions.parameterName from StaticConfigOptions where
> > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> > > FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> > > StaticConfigOptions.parameterLOCATION=ParameterLoc ation.parameterLocationID)
> > > LEFT JOIN Dependencies ON
> > > StaticConfigOptions.parameterID=Dependencies.param eterID) LEFT JOIN
> > > ParameterLocation AS ParameterLocation_1 ON
> > > Dependencies.DependencyID=ParameterLocation_1.para meterLocationID;
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9538
> > >
> > >
> > >
> > >
> > > "KARL DEWEY" wrote:
> > >
> > > > Try this --
> > > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > > ParameterLocation.parameterLocationDescription,
> > > > ParameterLocation_1.parameterLocationDescription AS [Dependent Location]
> > > > FROM ((StaticConfigOptions LEFT JOIN ParameterLocation ON
> > > > StaticConfigOptions.parameterLOCATION =
> > > > ParameterLocation.parameterLocationID) LEFT JOIN Dependencies ON
> > > > StaticConfigOptions.parameterID = Dependencies.parameterID) LEFT JOIN
> > > > ParameterLocation AS ParameterLocation_1 ON Dependencies.DependencyID =
> > > > ParameterLocation_1.parameterLocationID;
> > > >
> > > >
> > > > "Lisa" wrote:
> > > >
> > > > > Hi Karl,
> > > > >
> > > > > It didn't quite work for what is needed. Let me try and explain it a little
> > > > > more (I'll the true table names -- I thought real table names would be
> > > > > cumbersome, but I guess the opposite was true in this case, sorry)
> > > > >
> > > > > Table: StaticConfigOptions
> > > > > parameterID
> > > > > parameterName
> > > > > parameterLocation
> > > > > ...
> > > > >
> > > > > Table: ParameterLocation
> > > > > parameterLocationID
> > > > > parameterLocationDescription
> > > > > ...
> > > > >
> > > > > Table: Dependencies
> > > > > dependencyID
> > > > > parameterID
> > > > > dependency
> > > > >
> > > > > (the dependency table is a table with a primary key, dependencyID, and two
> > > > > foreign keys, both from the parameterID field from the StaticConfigOptions
> > > > > table)
> > > > >
> > > > > The Dependencies table is linked to the StaticConfigOptions table and the
> > > > > StaticConfigOptions table is also linked to the ParameterLocation table.
> > > > >
> > > > > So far I can get a query that tells me the Parameter Name, the Location, and
> > > > > the Dependency. What I'm missing is the Dependency Location. I can get the
> > > > > numerical value, but not that elusive parameterLocationDescription.
> > > > >
> > > > > Thank you very much for all your help!
> > > > >
> > > > > "KARL DEWEY" wrote:
> > > > >
> > > > > > I hard a hard time on this one as your table and field names do not match
> > > > > > those in the SQL. Also your SQL just would not fly as posted but I think I
> > > > > > figured out what you wanted. Try the SQL below and add or remove display
> > > > > > fields as you wish.
> > > > > >
> > > > > > SELECT StaticConfigOptions.parameterID, StaticConfigOptions.parameterName,
> > > > > > StaticConfigOptions.parameterLOCATION, Location.LocationDescription,
> > > > > > Location_1.LocationDescription AS [Dependent Location]
> > > > > > FROM (StaticConfigOptions LEFT JOIN Location ON
> > > > > > StaticConfigOptions.parameterLOCATION = Location.ID) LEFT JOIN (Dependencies
> > > > > > LEFT JOIN Location AS Location_1 ON Dependencies.DependencyID =
> > > > > > Location_1.ID) ON StaticConfigOptions.parameterID = Dependencies.parameterID;
> > > > > >
> > > > > >
> > > > > > "Lisa" wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have a question regarding building a query to get a relevant name for a
> > > > > > > foreign key.
> > > > > > >
> > > > > > > My database structure is as follows:
> > > > > > >
> > > > > > > Table:ConfigOptions
> > > > > > > ID
> > > > > > > Name
> > > > > > > Location
> > > > > > >
> > > > > > > Tableependencies
> > > > > > > ID
> > > > > > > ConfigOptionID
> > > > > > > DependencyID
> > > > > > >
> > > > > > > Table:Location
> > > > > > > ID
> > > > > > > LocationDescription
> > > > > > >
> > > > > > > What I need to do is build a query that returns ConfigOption Name,
> > > > > > > ConfigOption Location, Dependency Name, Dependency Location
> > > > > > >
> > > > > > > Using the following query, I can get the real name for ConfigOption Name,
> > > > > > > ConfigOption Location, and Dependency Name, but only the FK value for
> > > > > > > Dependency Location.
> > > > > > >
> > > > > > > SELECT StaticConfigOptions.parameterName AS Parameter,
> > > > > > > StaticConfigOptions.parameterLocation,
> > > > > > > (select StaticConfigOptions.parameterName from StaticConfigOptions where
> > > > > > > StaticConfigOptions.parameterID = Dependencies.dependency) AS Dependency,
> > > > > > > (select StaticConfigOptions.parameterLocation from StaticConfigOptions
> > > > > > > WHERE Dependencies.parameterID = StaticConfigOptions.parameterID) AS
> > > > > > > DependencyLocationID
> > > > > > > FROM StaticConfigOptions INNER JOIN Dependencies ON
> > > > > > > StaticConfigOptions.parameterID=Dependencies.param eterID;
> > > > > > >
> > > > > > > How do I get the real name (located in the parameterLocation table under
> > > > > > > LocationDescription) to appear?
> > > > > > >
> > > > > > > Whatever I try to do seems to crash Access.
> > > > > > >
> > > > > > > Thank you!!
> > > > > > >

Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Active Discussions
sikhism Who is "Mohan"?
Today 06:52 AM
21 Replies, 319 Views
sikhism need urgent advice.......
Today 06:46 AM
6 Replies, 72 Views
sikhism ਨਾਮਾ
Today 06:37 AM
2 Replies, 45 Views
sikhism Sikh Diamonds Video...
Today 04:23 AM
6 Replies, 112 Views
sikhism Are Creator and Creation...
Today 01:30 AM
44 Replies, 2,833 Views
sikhism Herman Hesse,...
Today 00:54 AM
13 Replies, 225 Views
sikhism On a Scale of Most...
Yesterday 21:42 PM
30 Replies, 1,277 Views
sikhism I became victim by...
Yesterday 19:50 PM
0 Replies, 39 Views
sikhism How important is Matha...
By Ishna
Yesterday 19:05 PM
58 Replies, 1,026 Views
sikhism Sikh Books downloads
Yesterday 15:39 PM
2 Replies, 62 Views
sikhism Salok Sheikh Farid ji...
Yesterday 09:35 AM
0 Replies, 43 Views
sikhism In Punjab, three farmers...
Yesterday 05:36 AM
0 Replies, 45 Views
sikhism Supernatural Sikhs, what...
Yesterday 03:45 AM
19 Replies, 408 Views
sikhism Sukhmani Sahib Astpadi...
26-May-2012 22:57 PM
0 Replies, 46 Views
Do You Think You Are...
26-May-2012 09:59 AM
94 Replies, 8,258 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 07:36 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 2.68262 seconds with 30 queries