473,396 Members | 1,743 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,396 software developers and data experts.

Left Joins in access

7
Hi Guys,

I'm having a few difficulties writing a left join query in access, below is what i've done in SQL but having a few problems getting the same result from access , any help is much appreciated.


SELECT tbl_employee_details.SOEID, tbl_employee_details.FirstName, tbl_employee_details.Surname, tbl_requests.RequestID,
tbl_Software_types.SoftwareName, tbl_hardware_types.HardwareTypes

FROM tbl_requests INNER JOIN

tbl_employee_details ON tbl_requests.SOEID = tbl_employee_details.SOEID LEFT JOIN

tbl_software_requests ON tbl_requests.RequestID = tbl_software_requests.RequestID LEFT JOIN
tbl_Software_types ON tbl_software_requests.ApplicationName = tbl_Software_types.ApplicationTypeID LEFT JOIN
tbl_hardware_requests ON tbl_requests.RequestID = tbl_hardware_requests.RequestID LEFT JOIN
tbl_hardware_types ON tbl_hardware_requests.HardwareType = tbl_hardware_types.HardwareTypeID


WHERE (tbl_employee_details.SOEID = '')
Jun 24 '10 #1
13 2532
code green
1,726 Expert 1GB
Try using brackets.
Not sure what the rules are but Access likes brackets
Jun 24 '10 #2
Daveyj
7
thanks for the response, but i really haven't a clue where to start,

any advice is greatly appreciated
Jun 24 '10 #3
Daveyj
7
when i do the above i get the missing operator message - please help i'm pulling my hair out
Jun 24 '10 #4
patjones
931 Expert 512MB
What does the message say, exactly? Does this SQL work in any other environments?

Pat
Jun 24 '10 #5
gershwyn
122 100+
Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_employee_details.SOEID,
  2.        tbl_employee_details.FirstName,
  3.        tbl_employee_details.Surname,
  4.        tbl_requests.RequestID,
  5.        tbl_software_types.SoftwareName,
  6.        tbl_hardware_types.HardwareTypes
  7. FROM (((((tbl_requests INNER JOIN tbl_employee_details ON tbl_requests.SOEID  = tbl_employee_details.SOEID)
  8. LEFT JOIN tbl_software_requests ON tbl_requests.RequestID = tbl_software_requests.RequestID)
  9. LEFT JOIN tbl_Software_types ON tbl_software_requests.ApplicationName = tbl_Software_types.ApplicationTypeID)
  10. LEFT JOIN tbl_hardware_requests ON tbl_requests.RequestID = tbl_hardware_requests.RequestID)
  11. LEFT JOIN tbl_hardware_types ON tbl_hardware_requests.HardwareType = tbl_hardware_types.HardwareTypeID)
  12. WHERE (tbl_employee_details.SOEID = '')
Note that there is a parenthesis at the end of each join and 5 before the first INNER JOIN.

I've always found this "feature" of Access annoying. Especially since when I tried to run your original query as written, it said the error was somewhere in the middle of the word 'detail'.
Jun 24 '10 #6
Daveyj
7
my initial code worked when i imported the access db into SQL -

Gershwn's code worked , but brings back no results.
Jun 24 '10 #7
gershwyn
122 100+
What results, if any, do you get when you remove the where clause?
Jun 24 '10 #8
patjones
931 Expert 512MB
Also bear in mind that there could be a difference between saying WHERE tbl_employee_details.SOEID = '' and WHERE tbl_employee_details.SOEID IS NULL. One is a zero-length string and the other is just, well, null. I have found that they both work in some circumstances, but not in others.

Pat
Jun 24 '10 #9
Daveyj
7
removed as double entry
Jun 24 '10 #10
Daveyj
7
i've used gershwyn post as an example and wrote the below query but it brings back duplicate results. any ideas?

SELECT Distinct tbl_employee_details.SOEID, tbl_employee_details.FirstName, tbl_employee_details.Surname, tbl_employee_details.StartDate, tbl_hardware_requests.HardwareType, tbl_hardware_requests.HardwareRequestNumber, tbl_software_requests.ApplicationName, tbl_software_requests.SoftwareRequestNumber, tbl_voice_requests.VoiceRequestType, tbl_voice_requests.VoiceRequestNumber
FROM ((tbl_employee_details INNER JOIN tbl_hardware_requests ON tbl_employee_details.SOEID=tbl_hardware_requests.S OEID) LEFT JOIN tbl_software_requests ON tbl_employee_details.SOEID=tbl_software_requests.S OEID) LEFT JOIN tbl_voice_requests ON tbl_employee_details.SOEID=tbl_voice_requests.SOEI D
WHERE (((tbl_employee_details.SOEID)=[Enter SOEID]));
Jun 24 '10 #11
code green
1,726 Expert 1GB
Duplicates are caused by a JOIN on a table that has more than one entry relating to the field that was joined.
There of course is nothing wrong with this as this is correct DB design.
You need to isolate a duplicate and decide what you want to filter out.
Jun 25 '10 #12
Daveyj
7
@code green
what is the best way to do that?
Jun 25 '10 #13
code green
1,726 Expert 1GB
The way I do it is look at the results.
select two or three employees that have a problem.
Then add a temporary addition to the WHERE clause

AND employee_id IN(id1,id2,id3)
Jun 25 '10 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Justin | last post by:
Hi. I decided to tidy up some of my queries, but I came across something that stumpt me: mysql> SELECT -> jobs.jobId, -> jobs.active, -> jobs.title, -> jobs.listed, -> ...
1
by: dan | last post by:
i have 2 tables that i want to count TABLE 1 categories --id --name forum_comments --id --category_id
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
2
by: ckirby | last post by:
I have a situation where I'm trying to add a text field to allow large Notes to be linked to record in an existing table (rather than simply adding the new field into the table since relatively...
1
by: ckirby | last post by:
I have a situation where I'm trying to add a text field to allow large Notes to be linked to record in an existing table (rather than simply adding the new field into the table since relatively...
3
by: mehdi | last post by:
I have a field that is a memo and I have a report displaying the text in that memo. What I need to know is how to "justify" the text right to left. The reason is in arabic and persian...
0
by: starman7 | last post by:
i want to exclude email addresses which are in newsletter_email_addresses which also appear in mooky_private.sign_ups.email and mooky.newsletter_opt_outs.email. my query seems to exclude the...
1
by: Eitan M | last post by:
Hello, I want to do select like this : select t1.col_2 from table_1 t1, table_2 t2 where t1.col_1 = t2.col_1 (+) The above is correct syntax for Oracle. What is the correct syntax for...
1
by: carrajo | last post by:
I'm working with access 2000 and I can't seem to get the query working: SELECT users.fullname, country.country, state.state FROM users, user_countries, country LEFT JOIN states ON...
1
by: silpa | last post by:
Hi, I have an SQL query like this select distinct t1.prodID from Table1 t1 left join Table2 t2 on t2.prodID = t1.prodID left join Table3 t3 on t3.serialno = t2.Id and t3.Qty = 0 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.