mysql - How to Inner JOIN Table A+B and reference TABLE A to multiple other tables -


im , doing outer join between table + b following:

select * player_img   left outer join user_play   on player_img.player_img_id = user_play.user_play_entry_player_img_id   , user_play.user_play_uid = 1   player_img.player_img_id null 

this gives me results table doesn't have reference table b user_play_uid = 1

in table a, have attributes reference other tables - im looking query out these fields also. quick example of table references:

table_a: player_img_id (unique key) player_img_player_id (reference to: table_c "player_id") player_img_category_id (reference to: table_d "category_id")  table_b: user_play_entry_player_img_id (reference table_a: "player_img_id") user_play_uid (reference table user.id)  table_c: player_id (unique key) player_country (reference table country.id) player_league (reference table league.id)  table_d: category_id (unique key) 

figured along way of following (which ofcourse doesnt work @ all):

select u . * , . * , pi . * , p . * , c . *   user u, user_play up, player_img pi, player p, country c   left outer join   on pi.player_img_id = up.user_play_entry_player_img_id   pi.player_img_id null   , up.user_play_uid = $this->user_id   , pi.player_img_category_id = $this->category_id   , pi.player_img_player_id = p.player_id   , p.player_country = c.country_id 

any suggestions on how combine outer join reference lookup tables across?

edit: current attempt below suggestions - query running no results showing - ideas?:/

select u . * , . * , pi . * , p . * , c . *   user u   inner join player_img pi   on pi.player_img_category_id  = 3   inner join player p   on pi.player_img_player_id    = p.player_id   inner join country c   on p.player_country           = c.country_id   left outer join user_play   on pi.player_img_id = up.user_play_entry_player_img_id   pi.player_img_id null   , up.user_play_uid      != 1 

use ansi-92 join syntax instead of old syntax using:

select u . * , . * , pi . * , p . * , c . * user u inner join player_img     pi on ... inner join player          p on pi.player_img_player_id = p.player_id inner join country         c on p.player_country        = c.country_id left outer join user_play on pi.player_img_id    = up.user_play_entry_player_img_id pi.player_img_id null   , up.user_play_uid = $this->user_id 

things note:

  • there no condition in query how join table player_img pi other tables.

  • the condition and up.user_play_uid = $this->user_id might remove unmcatched rows coming because of left join in case might need move condition subquery instead of left outer join table directly.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -