473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Creating self-join table

I'm trying to create a self-join table to show the relationship between
employee and supervisor. In another thread, I was advised to create a
SupervisorID in the employee table, a separate Supervisor table, and
join the Supervisor table to the Employee table and a copy of the
Supervisor table to create the self-join. I can't figure out how to do
this from reading Viescas or from researching it here. I can start a
query and create 2 copies of the Employee table, but it seems to me
that the table I want between them is the one created by the self-join.
It would have supervisor and employee(s), which is what the self-join
query is to create.
I also tried just joining 2 copies of the Employee table from
EmployeeID (PK) to SupervisorID in the other copy, but got a very
awkward table with employee's names in the left columns and suprvisors
and employee's names in the right columns with lots of blanks. Very
hard to read, though it did show each employee's supervisor. Just not
in any useful format.
I don't know SQL, which I'm gathering from research here is the
language of Access. I need an explanation in something clearer than SQL
shorthand, if possible. I know I'm asking a lot. (I'm getting signed up
for an Access class soon, which will help.) I need it in terms of
create a table with these columns, create a join by dragging from row x
in table a to row y in table b and select option 2 in the joins box.
That sort of thing.
My boss wants this and I've been working on it quite a while. Can
someone help me in plain English?

Nov 13 '05 #1
6 6272
>I also tried just joining 2 copies of the Employee table from
EmployeeID (PK) to SupervisorID in the other copy, but got a very
awkward table with employee's names in the left columns and suprvisors
and employee's names in the right columns with lots of blanks. Very
hard to read, though it did show each employee's supervisor. Just not
in any useful format.
This sounds like the approach I'd actually use, so can you explain why it
isn't in a useful format? What is the format you are after?
I don't know SQL, which I'm gathering from research here is the
language of Access. I need an explanation in something clearer than SQL
shorthand, if possible. I know I'm asking a lot. (I'm getting signed up
for an Access class soon, which will help.) I need it in terms of
create a table with these columns, create a join by dragging from row x
in table a to row y in table b and select option 2 in the joins box.
That sort of thing.


Happy to do that, but the reason why people post SQL is because it's more
precise than trying to explain what to drag where and why. Did you know that
you can just cut and paste SQL into a query? When you are in Query Designer,
the top left button shows a datagrid, and if you click on it, the query runs
and the results are displayed. The button then displays a tri-square, and if
you click on that, it takes you back to Query Designer. However, you can also
click on the drop down next to the button, and it will show another option
called "SQL". If you click on that, the undeerlying SQL for the query will be
displayed. At that point, you can paste in the SQL that people post here or
elsewhere, and then you can swithc back to the Query Designer view to see
what it looks like in there. The SQL itself can be quite daunting, but when
you see it in Query Designer, it can make a lot more sense.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1
Nov 13 '05 #2

David S via AccessMonster.com wrote:
I also tried just joining 2 copies of the Employee table from
EmployeeID (PK) to SupervisorID in the other copy, but got a very
awkward table with employee's names in the left columns and suprvisors
and employee's names in the right columns with lots of blanks. Very
hard to read, though it did show each employee's supervisor. Just not
in any useful format.
This sounds like the approach I'd actually use, so can you explain why it
isn't in a useful format? What is the format you are after?


Thanks for your reply.
The table created by the query contains the first name, last name and
employee ID of each employee, followed by the same information for
their supervisor. the problem is that every employee appears in both
sets of columns, including those that are not supervisors appearing in
the "supervisor" set of columns. So most of the names in the supervisor
columns have no corresponding name in the "employee" columns, just
blanks.
What I'd rather have is 2 views. One listing each employee and a
subdatasheet of their supervisor, and another of supervisors only, with
a subdatasheet of the employees they supervise.
I don't know SQL, which I'm gathering from research here is the
language of Access. I need an explanation in something clearer than SQL
shorthand, if possible. I know I'm asking a lot. (I'm getting signed up
for an Access class soon, which will help.) I need it in terms of
create a table with these columns, create a join by dragging from row x
in table a to row y in table b and select option 2 in the joins box.
That sort of thing.
Happy to do that, but the reason why people post SQL is because it's more
precise than trying to explain what to drag where and why. Did you know that
you can just cut and paste SQL into a query? When you are in Query Designer,
the top left button shows a datagrid, and if you click on it, the query runs
and the results are displayed. The button then displays a tri-square, and if
you click on that, it takes you back to Query Designer. However, you can also
click on the drop down next to the button, and it will show another option
called "SQL". If you click on that, the undeerlying SQL for the query will be
displayed. At that point, you can paste in the SQL that people post here or
elsewhere, and then you can swithc back to the Query Designer view to see
what it looks like in there. The SQL itself can be quite daunting, but when
you see it in Query Designer, it can make a lot more sense.


I understand why they use it. And if that's a condition for getting
help here, I'll accept that and try and find help elsewhere, since I
don't plan on learning SQL in the forseeable future. I'm in the middle
of learning Excel VBA and Access, and my capacity to absorb new
material is being stretched as it is. Oh yes, I just started a new job
in an entirely new field and am trying to figure out what I'm doing
each day. So I have a new job to do while I'm learning all this. I am
in the process of signing up for a 2 day beginner class in Access. I'm
sure it will help, and I'll bring lots of specific questions, like how
do I create a self-join in Access. I don't really want to create it
using SQL unless I have to. I understand the intricasies and pitfalls
of writing code, and just don't want the complications in my work right
now, at least not the additional ones!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1


Nov 13 '05 #3
>I understand why they use it. And if that's a condition for getting
help here, I'll accept that and try and find help elsewhere, since I
don't plan on learning SQL in the forseeable future.
It's not a precondition, it's just that it will be harder to give you help
that you will be able to understand & implement. It's certainly not
impossible, and I'll try, but we may have some back & forth as we try to
clarify what exactly each of us means by a particular statement :) It does
sound like you've got a lot on your plate, but if you do get a chance, I'd
say SQL is definitely well worth learning, since you can use it not only for
Access, but pretty much any relational database out there. But back to your
immediate requirements:
The table created by the query contains the first name, last name and
employee ID of each employee, followed by the same information for
their supervisor. the problem is that every employee appears in both
sets of columns, including those that are not supervisors appearing in
the "supervisor" set of columns. So most of the names in the supervisor
columns have no corresponding name in the "employee" columns, just
blanks. Mm - the employees should only appear in the left hand set of columns, and
only supervisors should appear multiple times in the right hand set of
columns. I suspect the join between the two versions of the same table hasn't
been defined properly. In the Query Designer, one version of the table should
appear as "Employee" and the other as "Employee_1". There should be a join or
line from SupervisorID in Employee to EmployeeID in Employee_1. If the line
has dots at both ends rather than an arrow, it is an "inner join", meaning
that only those Employees with a Supervisor will be displayed. If you want
all Employees to be shown irrespective of whether they have a Supervisor, you
need a "Left Outer Join" - right click on the join line and choose "Join
Properties", and then choose "Include ALL records from 'Employee' etc". This
should give you all Employees and who their Supervisor is.
What I'd rather have is 2 views. One listing each employee and a
subdatasheet of their supervisor, and another of supervisors only, with
a subdatasheet of the employees they supervise.

I'm afraid I don't understand what you mean by "subdatasheet". The query
above will produce the employees with their supervisors; you can make it
supervisor centric by sorting it by SupervisorID in Employee first. Then, you
can write a report for the output the hides the duplicate entries in the
query. If you want to display the output on a table in a form, I'm afraid
you're going to need to ask over in the Forms or Forms Programming forum -
I'm not very good at that part of the MS Access world...
--
Message posted via http://www.accessmonster.com
Nov 13 '05 #4
David, Thanks for your reply. I did exactly what you said, and it
worked great! I now have a table that lists all employees in the left
columns, and supervisors only on the right. I had the join wrong. I
want to reply to your message more specifically:

David S via AccessMonster.com wrote:
I understand why they use it. And if that's a condition for getting
help here, I'll accept that and try and find help elsewhere, since I
don't plan on learning SQL in the forseeable future.
It's not a precondition, it's just that it will be harder to give you help
that you will be able to understand & implement. It's certainly not
impossible, and I'll try, but we may have some back & forth as we try to
clarify what exactly each of us means by a particular statement :) It does
sound like you've got a lot on your plate, but if you do get a chance, I'd
say SQL is definitely well worth learning, since you can use it not only for
Access, but pretty much any relational database out there. But back to your
immediate requirements:


I should explain, I'm not a database person, I'm an Excel expert. The
only reason I'm doing this project in Access is that my boss decided I
can learn any software quickly and easily and she asked me to do this
employee database. I think I've showed her with this project that her
she was wrong about my capabilities!
The table created by the query contains the first name, last name and
employee ID of each employee, followed by the same information for
their supervisor. the problem is that every employee appears in both
sets of columns, including those that are not supervisors appearing in
the "supervisor" set of columns. So most of the names in the supervisor
columns have no corresponding name in the "employee" columns, just
blanks. Mm - the employees should only appear in the left hand set of columns, and
only supervisors should appear multiple times in the right hand set of
columns. I suspect the join between the two versions of the same table hasn't
been defined properly. In the Query Designer, one version of the table should
appear as "Employee" and the other as "Employee_1". There should be a join or
line from SupervisorID in Employee to EmployeeID in Employee_1. If the line
has dots at both ends rather than an arrow, it is an "inner join", meaning
that only those Employees with a Supervisor will be displayed. If you want
all Employees to be shown irrespective of whether they have a Supervisor, you
need a "Left Outer Join" - right click on the join line and choose "Join
Properties", and then choose "Include ALL records from 'Employee' etc". This
should give you all Employees and who their Supervisor is.


That's what I have now. Great!
What I'd rather have is 2 views. One listing each employee and a
subdatasheet of their supervisor, and another of supervisors only, with
a subdatasheet of the employees they supervise. I'm afraid I don't understand what you mean by "subdatasheet". The query
above will produce the employees with their supervisors; you can make it
supervisor centric by sorting it by SupervisorID in Employee first. Then, you
can write a report for the output the hides the duplicate entries in the
query. If you want to display the output on a table in a form, I'm afraid
you're going to need to ask over in the Forms or Forms Programming forum -
I'm not very good at that part of the MS Access world...


Maybe you have an older version of Access, or just haven't used that
feature. I have 2000 and it has the capability to show a datasheet
where each record has a + or - next to it. If it has a +, I can click
on the + and a subdatasheet appears under the record with whatever
table I've chosen. I've tried it with the new datasheet your query
created and it's the entire datasheet, not just the data from the
selected record, which is what I want in it. So I'll have to do more
work on that.

--
Message posted via http://www.accessmonster.com


I appreciate your patience and help.

Nov 13 '05 #5
>Maybe you have an older version of Access, or just haven't used that
feature. I have 2000 and it has the capability to show a datasheet
where each record has a + or - next to it. If it has a +, I can click
on the + and a subdatasheet appears under the record with whatever
table I've chosen. I've tried it with the new datasheet your query
created and it's the entire datasheet, not just the data from the
selected record, which is what I want in it. So I'll have to do more
work on that.
I do have Access 2000 - it sounds like the feature I've seen before when two
tables have a defined relationship, rather than just being joined in a query.
I've not done much with it, though.
I appreciate your patience and help.


Glad to have been of help - hope you get to the end of this without your
brain exploding :)
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1
Nov 13 '05 #6

David S via AccessMonster.com wrote:
Maybe you have an older version of Access, or just haven't used that
feature. I have 2000 and it has the capability to show a datasheet
where each record has a + or - next to it. If it has a +, I can click
on the + and a subdatasheet appears under the record with whatever
table I've chosen. I've tried it with the new datasheet your query
created and it's the entire datasheet, not just the data from the
selected record, which is what I want in it. So I'll have to do more
work on that.


I do have Access 2000 - it sounds like the feature I've seen before when two
tables have a defined relationship, rather than just being joined in a query.
I've not done much with it, though.
I appreciate your patience and help.


Glad to have been of help - hope you get to the end of this without your
brain exploding :)


Too late! :)

Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
1
by: Will McGugan | last post by:
Hi, Is there any way of making properties using a decorator? The current way of creating a property seems inelegant. Something like this imaginary snippit would be nice, IMHO. class...
4
by: NutJob | last post by:
Hello, I'm faced with the following problem: I have a (secondary) thread that monitors a socket for incoming message traffic using the select.select() function. Besides that I also have the...
7
by: Michael Williams | last post by:
Hi All, I'm looking for a quality Python XML implementation. All of the DOM and SAX implementations I've come across so far are rather convoluted. Are there any quality implementations that...
10
by: connyledin | last post by:
Im trying to create a version of the game Wumpus. Mine is called Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can some one help me?? here is the file:...
17
by: Lee Harr | last post by:
I understand how to create a property like this: class RC(object): def _set_pwm(self, v): self._pwm01 = v % 256 def _get_pwm(self): return self._pwm01 pwm01 = property(_get_pwm, _set_pwm)
6
by: wcc | last post by:
Hello, How do I create a class using a variable as the class name? For example, in the code below, I'd like replace the line class TestClass(object): with something like class...
3
by: Thomas Jansson | last post by:
Dear all I am writing a program with tkinter where I have to create a lot of checkbuttons. They should have the same format but should have different names. My intention is to run the functions...
1
by: kaens | last post by:
So, I have a class that has to retrieve some data from either xml or an sql database. This isn't a problem, but I was thinking "hey, it would be cool if I could just not define the functions for...
14
by: tdahsu | last post by:
I have twenty-five checkboxes I need to create (don't ask): self.checkbox1 = ... self.checkbox2 = ... .. .. .. self.checkbox25 = ... Right now, my code has 25 lines in it, one for each...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.