Hi Lee,
Not sure where you got the notion of an "output" alias, I don't think
that's
a helpful way of looking at it. If you got it from Access help or a book
or
something, then that is just plain sloppy (of whoever wrote it, I mean,
not
you!).
Once you've aliased a table, you *must* refer to it using the alias
everywhere else in the query. If you selected Tbl.name you would get an
error, and quite right too: Access would not know which "name" field you
were referring to, the one in Tbl1 or the one in Tbl2. It matters too,
because we're only selecting one name from Tbl2, but we are potentially
selecting lots of names from Tbl1.
n.b. As someone else pointed out, "name" is not a good name for a field,
I
do recommend that you change it to something that isn't a reserved word.
HTH
Baz
Lee Hunter said:
I get almost all EXCEPT....
SELECT Tbl1.name FROM Tbl AS Tbl1
Why can it be Tbl1.name or not have to be Tbl.name?
I thought the AS clause defined a an "output" alias.
Not true? If so,how canyou SELECT from the "output"?
I know it's a "fine point" but I really am trying to understand.
thanks again.
This is a piece of art
:
I'll try!
The key to it is to pretend that you have two separate tables: the one
from
which you are selecting the first name/team (by dodate), and the one
from
which you are selecting all of the team members.
This is achieved by the use of aliases: by naming (aliasing) the same
table
once as Tbl1 and again as Tbl2, we can treat Tbl1 and Tbl2 as two
different
tables. We can then select the first name/team from Tbl2 (using the
WHERE
clause), and join it to Tbl1 to get all of the team members.
Solutions using a sub-query will also work, but they are cumbersome by
comparison and tend to be slow in Access.
Hope that helps!
Baz
What a great innovative solution!
Perfect result.
Would you please explain how (why) it works?
:
Maybe this (warning: untested):
SELECT Tbl1.name FROM Tbl AS Tbl1 INNER JOIN Tbl AS Tbl2 ON
Tbl1.team
=
Tbl2.team WHERE Tbl2.dodate = [Please Enter the Do Date]
Tbl is as follows;
name, dodate, team.
I must first select the single name that matches a specific
dodate,
then
select all the names that match the team of the first selected
name,
regardles of what their date is.
Short of running a make table for the first select, then using
that
as
a
join with the original tbl, what other options are available?
Thanks for the help.