PC Review


Reply
Thread Tools Rate Thread

Access 2000 query help (please!?)

 
 
Josh C.
Guest
Posts: n/a
 
      9th Jan 2008
Hi there guys,

I am trying to devise a query and its just not coming to me. I'm hoping
someone out there can help.
I am trying to create a query that will give me the distinct value from two
columns in the same table. Here is what its like:

Table1: Schools
Columns: school_id, school_abbrev, school_name

Table2: Travel_Log
Columns: log_to, log_from (these are numerics that tie to school_id above)

So I want to create a list of all the schools visited in the travel log, so
I want the distince values of log_to and log_from and then list them out with
their abbreviations and full names in the list. If it were just a distinct
value of one of those columns it would be easy, but I can't figure out how to
get both to work.

I hope that made sense. I would really appreciate any suggesstions.

Thanks in advance,

Josh


 
Reply With Quote
 
 
 
 
Roger Converse
Guest
Posts: n/a
 
      9th Jan 2008
Hello,

Your post is somewhat confusing...

....so I want the distince values of log_to and log_from...

Did you mean distinct?

I would run a few different steps here. First would be to query your school
ID by log_to grouping on both and then the same query with log_from (no
log_to). Then I would create another query that finds the schools in common
(a log_to and log_from) entry and combine those. Lastly run an unmatched
query and append any unmatched records.

I am not sure you can do what you are trying to do with just one query, but
that should get the job done.

HTH
Thanks,
Roger

"Josh C." wrote:

> Hi there guys,
>
> I am trying to devise a query and its just not coming to me. I'm hoping
> someone out there can help.
> I am trying to create a query that will give me the distinct value from two
> columns in the same table. Here is what its like:
>
> Table1: Schools
> Columns: school_id, school_abbrev, school_name
>
> Table2: Travel_Log
> Columns: log_to, log_from (these are numerics that tie to school_id above)
>
> So I want to create a list of all the schools visited in the travel log, so
> I want the distince values of log_to and log_from and then list them out with
> their abbreviations and full names in the list. If it were just a distinct
> value of one of those columns it would be easy, but I can't figure out how to
> get both to work.
>
> I hope that made sense. I would really appreciate any suggesstions.
>
> Thanks in advance,
>
> Josh
>
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      9th Jan 2008
On Wed, 9 Jan 2008 05:16:02 -0800, Josh C. <(E-Mail Removed)>
wrote:

>Hi there guys,
>
>I am trying to devise a query and its just not coming to me. I'm hoping
>someone out there can help.
>I am trying to create a query that will give me the distinct value from two
>columns in the same table. Here is what its like:
>
>Table1: Schools
>Columns: school_id, school_abbrev, school_name
>
>Table2: Travel_Log
>Columns: log_to, log_from (these are numerics that tie to school_id above)
>
>So I want to create a list of all the schools visited in the travel log, so
>I want the distince values of log_to and log_from and then list them out with
>their abbreviations and full names in the list. If it were just a distinct
>value of one of those columns it would be easy, but I can't figure out how to
>get both to work.
>
>I hope that made sense. I would really appreciate any suggesstions.
>
>Thanks in advance,
>
>Josh
>


I think you need to add the Schools table to the query *twice* - once linked
to log_from and once linked to log_to. The SQL might be

SELECT Table2.<whatever you want to see>, SchoolFrom.School_abbrev AS FromA,
SchoolFrom.School_Name As FromN, SchoolTo.School_abbrev AS ToA,
SchoolTo.School_Name AS ToN
FROM (Table2 INNER JOIN Table1 AS SchoolFrom ON Table1.log_from =
SchoolFrom.school_id) INNER JOIN Table1 AS SchoolTo ON table1.log_2 =
SchoolTo.school_id);

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2000 Query very slow compared to SQL Query Analyzer WB Microsoft Access Queries 5 19th Jan 2010 04:52 AM
No query result when running an Access 2000 dbase in Access 2002 =?Utf-8?B?UEI=?= Microsoft Access Queries 2 26th Jul 2005 02:49 AM
Query referencing sub-sub-form works in Access 2000 / fails in Access 2003 Bob Howard Microsoft Access Forms 1 7th May 2005 03:22 AM
make table query - Access 2000 on Windows 2000 Diann Microsoft Access Queries 1 20th Nov 2003 10:34 PM
Exporting Query from access 2000 to Excel 2000 Sean Microsoft Access External Data 2 8th Nov 2003 02:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.