database - What's the reason of getting Mysql 50000 rows from 4919 rows left join 4919 rows? -


select * from( (select a1.*, a2.id2, a2.id3, a2.type1, a2.type2, a2.type3 from( (select a.id, a.id1, a.id2, a.id3, a.id4,  b.id5, b.id6, b.id7, b.id8, b.id8, b.id9, b.id10 from( (select id, id1, id2, id3, id4 record1) left join (select id, id1, id2, id3, id4, id5, id6, id7 record2) b  on a.id = b.id1)) a1 left join (select id, id1, id2, id3, id4, id5, id6, id7, id8, type1, type2, e.ttype3 type3 from( (select id, id1, id2, id3, id4, id5, id6, id7, id8, bb.type1, cc.d.type type2 from( (select id, id1, id2, id3, id4, id5, id6, id7, id8, bb.c.type type1 from( (select a.*, b.id1, b.type, b.id3, b.id4, id5 from( (select * record) left join (select * record2) b on a.id = b.id1)) aa left join (select type, id ttype1 record2 type='small') c on aa.id = c.ttype1)) bb left join **strong text** (select type, id ttype2 record2 type='medium') d on bb.id = d.ttype2)) cc left join (select type, id ttype3 record2 type='large') e on cc.id = e.ttype3)) a2 on a1.id3 = a2.id3)) a3 left join   # a3 first part 4919 rows (select a.id1, a.id2, b.id3, b.id4, b.id5, b.id6, b.id7, b.id8, b.id9, b.id1, b.id2, b.id3, b.id4, b.id5, b.id6, b.id7 from( (select * record1) left join (select * record3) b on a.id1 = b.id)) a4 on a3.id1 = a4.id1) on a3.id1 = a4.id1)) a5 left join #a4 has 4919 rows, , a5 has 50000 rows. 

as shown in comment, question how got result 50000 rows after left join of 2 4919 rows?

your code extraordinarily hard understand. it's clear you're working human health data, it's critical reformat allow inspected.

i suspect have @ least 1 (left) join clause without on qualifier. cause combinatorial explosion, gives rows.

format sql can read logic. suggest use sort of format.

       select col, col, col         table    left join (                select thing, thing, thing                 anothertable              ) b on a.index = b.a_index , b.criterion = 'something'    left join patient p on p.id = a.id 

do see how can @ kind of query, seeing tables , subqueries go it? see how can inspected accuracy?

i tried, , failed, make sense of query reformatting way. you're 1 knows logic, it's that.

(if got programmer, have condolences! still have sort out rational format.)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -