mysql - join 2 tables to bring multiple column's using one single join -
i have table table1
pid_x pid_y count b 5 c 10 b 20 c e 3 d g 7 e f 10 e b 20
and on (more 1 million rows)
also have master_table
consists details
pid rating_pid price_pid 2 10 b 4 20 c 1 30 d 3.5 40 e 2.4 50 f 1.5 60 g 3.8 70
(and on, huge table master_table
)
also have score_table
.
pid score_p_id 7 b 1 c 4 d 3.5 e 4 f 5 g 3
what looking is, final_table
has columns
pid_x pid_y final_score price_pid_y rating_pid_y price_diff_pidy/x
explanation.
create final table has column's pid_x
, pid_y
, final_score pid_y (score +count) score table pid=pid_y
, join price , rating
of pid_y master_table's
pid
, price difference percentage of pid_y respect pid_x.
final_table
should this
pid_x pid_y final_score price_pid_y rating_pid_y price_diff_pid_y/x b 6 20 4 200 c 14 30 1 300 b 27 10 2 50
the table very huge, want optimized solution it
what thinking join these 3 tables? there solution/insights it?
join score , master_table once, ,
intermediate_table
joinintermediate table
table1 way achieve this?
Comments
Post a Comment