Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Filter many tables in query with the same where-condition
cgm
<p>Hello,</p><p> </p><p>I have an problem in the query that I use for my reports:</p><p> </p><p>My query is a little more complex and I'm trying to shrink it.</p><p>I'm using Report Parameter to filter my report result at runtime. Therefore I have to filter different tables in my MySQL Database with the same sub-statement.</p><p> </p><p>A sample:</p><p>Select *</p><p>from table1 where person in (Select person from Persons where name like ?)</p><p>join table2 on (..) where person in (Select person from Persons where name like ?)</p><p>join table3 on (...) where person in (Select person from Persons where name like ?)</p><p>join table4 on (...) where person in (Select person from Persons where name like ?)</p><p> </p><p>...and so on</p><p> </p><p>Is there no easier way so that I don't need to execute the same "select-pattern" in the where clause multiple times?</p><p> </p><p>Can anybody help?</p><p> </p><p>Regards</p><p>Marco</p>
Find more posts tagged with
Comments
Hans_vd
<p>Not sure why you have to repeat that subselect for every table... can't you add person to the join conditions?</p>
cgm
<p>I need to repeat that subselect,because there are many tables, which have to be filtered by persons.The tables are very huge, so that I need to shrink them before joining. The list of persons depends on a the selection of a report parameter (choose project --> persons in project). Sorry for the bad explanation, hope you can understand what I mean.</p>
Hans_vd
<p>>> [color=rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;]The tables are very huge, so that I need to shrink them before joining[/color]</p><p> </p><p>So I ask again: Can't you add person to the join condition?</p><p> </p><p>I presume you want to shrink the huge tables before joining to improve performance? Well, it probably won't.</p>