Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT * FROM
- information_schema.columns cl
- INNER JOIN
- information_schema.columns cr
- ON
- cl.table_name < cr.table_name AND
- cl.data_type = cr.data_type
- SELECT
- REPLACE(REPLACE(REPLACE(REPLACE(
- 'SELECT ''{Ltable}.{Lcol}'' as lefty, ''{Rtable}.{Rcol}'' as righty, count(l.{Lcol}) as countLefty, count(r.{Rcol}) as countRighty, case when count(r.{Rcol}) = 0 then 0 else count(l.{Lcol})/count(r.{Rcol}) end as percenty
- FROM {Ltable} l LEFT JOIN {Rtable} r ON l.{Lcol} = r.{Rcol} UNION ALL',
- '{Ltable}', cl.table_name),
- '{Rtable}', cr.table_name),
- '{Lcol}', cl.column_name),
- '{Rcol}', cr.column_name)
- FROM
- information_schema.columns cl
- INNER JOIN
- information_schema.columns cr
- ON
- cl.table_name < cr.table_name AND
- cl.data_type = cr.data_type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement