mysql - Dynamic MySQLTable -


here's situation. have 9 tables in database have c_no (int), cl_no (int), , status (boolean). need know best way create dynamic table distinctly shows c_no, cl_no, , table comes denoted number.

the difficult part making reactive or dynamic status 1's. lets updates 1 of statuses need record removed. also, if updates 1 of cl_no new 1 need inserted table , if cl_no c_no doesn't exist anymore origin table need removed well. need up-to-date table consolidates info.

example:

table_one

c_no, cl_no, status

1,1,1

1,2,1

1,1,1

1,1,1

1,1,0

table_two

c_no, cl_no, status

1,10,1

1,3,1

1,32,1

1,1,0

desired_table

c_no,cl_no,ref_table

1,1,1

1,2,1

1,32,2

1,3,2

1,10,2

i have tried following without success,

1.) creating view ran @ 50+ secs, need return result in under 1 seconds. 9 joins, query ran long.

2.) creating triggers each table, when importing or updating 10,000 records response time exponentially increase on 2 minutes in test cases.

sorry poor format. thank in advanced time , help!!

your looking union statement think. along lines of

select c_no, cl_no, 1 table_one status = 1 union select c_no, cl_no, 1 table_two status = 1 

if stick view dynamic , freely available. assume not needing remove or deal duplicates in way between 2 tables. query need changed manage that.

your other option union like

select c_no, cl_no, table_id ( select c_no, cl_no, 1 table_id, status table_one union select c_no, cl_no, 1 table_id, status table_two ) lookup status = 1 

neither of these queries have been tested should give ideas options

what original query?


Comments