Getting all NOT matching entries across a link table in ms-access -


i have following relations in database: relations

there different trainings in company , repeated 2-3 times year.

now want tbl_events entries tbl_employee entry has no relation , display them in report.

so far, i've tried make query giving me employess ev_name visited.

qry_visited:

select tbl_employee.em_number     ,tbl_event.id ev_visited_id (     tbl_event inner join tbl_date on tbl_event.[id] = tbl_date.[da_f_event]     ) inner join (     tbl_employee inner join tbl_training on tbl_employee.[id] = tbl_training.[tr_f_employee]     ) on tbl_date.[id] = tbl_training.[tr_f_date]; 

and wrote second query: qry_unvisited

select qry_visited.em_number     ,tbl_event.ev_name     ,qry_visited.ev_visited_id qry_visited right join tbl_event on qry_visited.ev_visited_id = tbl_event.id (((qry_visited.ev_visited_id) null)); 

these queries work together, if limit first 1 1 employee. rather have 1 recordset em_number , ev_name employees.

i researched couple of days on working (and working around) left outer, right outer , full outer join, none did trick.

thanks help!

edit 1

example: there 3 employees (emp1, emp2, epm3) , 3 events (ev1, ev2, ev3)

let's say

  • emp1 visited ev1 , ev2
  • emp2 visited ev2 , ev3
  • emp3 visited none far

i want result this:

| employee | not visited events |   emp1       ev3   emp2       ev1   emp3       ev1   emp3       ev2   emp3       ev3 

this should give list of events no related employees.

select distinctrow tbl_event.* ((tbl_event left join tbl_date on tbl_event.id = tbl_date.da_f_event) left join tbl_training on tbl_date.id = tbl_training.tr_f_date) left join tbl_employee on tbl_training.tr_f_employee = tbl_employee.id tbl_employee.id null 

if understand correctly, want possible employee-event combinations, excluding ones happened.

something this:

select possibles.* (     select tbl_event.id eventid, tbl_employee.id empid     tbl_event, tbl_employee ) possibles left join (     select tbl_date.da_f_event eventid, tbl_training.tr_f_employee empid     tbl_date     inner join tbl_training on tbl_date.id = tbl_training.tr_f_date ) actuals on possibles.eventid = actuals.eventid , possibles.empid = actuals.empid actuals.eventid null 

you can add more fields tbl_event , tbl_employee possibles subquery.


following informal description of join types:

inner join

includes records match on both sides of join; duplicates records multiple matches

select tbl_event.*, tbl_date.* tbl_event inner join tbl_date on tbl_event.id = tbl_date.da_f_event 

left join

includes records first table, , records match second table. second-table columns rows without match in second table have value of null. duplicates records multiple matches.

select tbl_event.*, tbl_date.* tbl_event left join tbl_date on tbl_event.id = tbl_date.da_f_event 

(there right join, same except reverses order of tables. haven't yet found reason use right join, suggest avoid it.)

full outer join (not supported ms access)

includes records both tables when there no match given record on other side of join. duplicates records multiple matches.

select tbl_event.*, tbl_date.* tbl_event full outer join tbl_date on tbl_event.id = tbl_date.da_f_event 

cross join, aka cartesian product

includes each record first table each record in second table.

select tbl_event.*, tbl_date.* tbl_event, tbl_date 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -