I have two tables which look like this:
Jun 12, 2017 Okay, you have to JOIN all three tables with the trainingRecords table in the middle because it has the columns necessary to link the other two tables. Your query will look something like this: SELECT E.lName, E.fName, ML.docName, ML.docNumber FROM (employees E LEFT OUTER JOIN trainingRecords TR ON E.empID = TR.empID) RIGHT OUTER JOIN masterList ML ON ML.TID. How to define relationships between tables in an Access database. Content provided by Microsoft. If you want to add the tables that you want to relate but the Show Table dialog box does not appear. Create the two tables that will have a many-to-many relationship.
I basically need to join these tables when their IDs, dates, and hours match. However, I only want to return the results from table 1 that do not match up with the results in table 2.
I know this seems simple, but where I'm stuck is the fact that there are multiple rows in table 1 that match up with table 2 (there are multiple intervals for any given hour). I need to return all of these intervals so long as they do not fall within the same hour period in table 2.
Example data:
My expected result set for this would be the last two rows from
T1
. Can anyone point me on the right track?BreakthroughBreakthrough
2 Answers
Joe StefanelliJoe Stefanelli
Use a
LEFT JOIN
and filter out the lines that have non-NULL
T2 columns:Costi CiudatuCosti Ciudatu
Not the answer you're looking for? Browse other questions tagged sqlms-accessjoin or ask your own question.
Okay.
I've been put on a project at work, and though I've got some SQL skills, they are very rusty.
One of the scenarios at work has left me with a number of tables with values I need to sum up. They are not linked either, but the order is the same across all the tables.
Basically, I would like to take this two tables:
To get an output like this to feed into a graphing application:
Please help.
Uchenna EbilahUchenna Ebilah
closed as off-topic by Taryn♦, JoseK, Chris Kempen, Praveen, marseiOct 18 '13 at 7:51
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist' – Taryn, JoseK, Chris Kempen, Praveen, marsei
4 Answers
JonysuiseJonysuise
vectorvector
you can also try this in sql-server !!
or try using sum,union
vhadalgivhadalgi
For your current structure, you could also try the following:
I think I prefer a union between the two tables, and a group by on the country name as mentioned above.
But I would also recommend normalising your tables. Ideally you'd have a country table, with Id and Name, and a payments table with:CountryId (FK to countries), Total, Type (cash/cheque)
Mathew CollinsMathew Collins