php - Retrieving aggregated results from two queries -


i trying figure out best way compare results 2 queries , display difference.

  • table 1 = user table
  • table 2 = page table
  • table 3 = assigned table

example: there users 1 , users 2 in user table. user 1 has been assigned 10 pages, user 2 has been assigned 1 page.

this works fine finding pages have assigned, 1 page example.

select * assigned_table user= 2 

but can not figure out how results of other pages doesn't have access to.

this not work because there user 1 has access 10, gets results of other users except user2

select * assigned_table user != 2 

so need pages user2 have access to, , pages not have access , display both results separately

any assistance appreciated.

sorry if similar topic posted elsewhere, unable find looking for.

you should use join this. here's documentation on https://dev.mysql.com/doc/refman/5.0/en/join.html.

something like

select pt.pagename `assigned table` @ join `page table` pt on at.pageid = pt.id at.user = 2 

this give listing of page titles (pagename) user 2 has assigned him/her. column , table names need updated.

pull papers not assigned specific user.

select pagename  `page table`  id not in (select pageid `assigned table` at.user = 2) 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -