Mysql从多表中(100个表)查询满足条件数据。

作者: jiukeshuju 分类: MYSQL 发布时间: 2020-01-25 20:03

Mysql从多表中查询满足条件数据

 

创建存储过程从100表中选出满足条件的数据:

  1. 通过对bizNo进行hash路由查出所在的(库)表
  2. 使用联合查询查找(存储过程拼接sql查询,直接用sql语句进行查询)

select * from
(
select * from task_000 union all
select * from task_001 union all
select * from task_002 union all
select * from task_003 union all
select * from task_004 union all
select * from task_005 union all
select * from task_006 union all
select * from task_007 union all
select * from task_008 union all
select * from task_009 union all
select * from task_010 union all
select * from task_011 union all
select * from task_012 union all
select * from task_013 union all
select * from task_014 union all
select * from task_015 union all
select * from task_016 union all
select * from task_017 union all
select * from task_018 union all
select * from task_019 union all
select * from task_020 union all
select * from task_021 union all
select * from task_022 union all
select * from task_023 union all
select * from task_024 union all
select * from task_025 union all
select * from task_026 union all
select * from task_027 union all
select * from task_028 union all
select * from task_029 union all
select * from task_030 union all
select * from task_031 union all
select * from task_032 union all
select * from task_033 union all
select * from task_034 union all
select * from task_035 union all
select * from task_036 union all
select * from task_037 union all
select * from task_038 union all
select * from task_039 union all
select * from task_040 union all
select * from task_041 union all
select * from task_042 union all
select * from task_043 union all
select * from task_044 union all
select * from task_045 union all
select * from task_046 union all
select * from task_047 union all
select * from task_048 union all
select * from task_049 union all
select * from task_050 union all
select * from task_051 union all
select * from task_052 union all
select * from task_053 union all
select * from task_054 union all
select * from task_055 union all
select * from task_056 union all
select * from task_057 union all
select * from task_058 union all
select * from task_059 union all
select * from task_060 union all
select * from task_061 union all
select * from task_062 union all
select * from task_063 union all
select * from task_064 union all
select * from task_065 union all
select * from task_066 union all
select * from task_067 union all
select * from task_068 union all
select * from task_069 union all
select * from task_070 union all
select * from task_071 union all
select * from task_072 union all
select * from task_073 union all
select * from task_074 union all
select * from task_075 union all
select * from task_076 union all
select * from task_077 union all
select * from task_078 union all
select * from task_079 union all
select * from task_080 union all
select * from task_081 union all
select * from task_082 union all
select * from task_083 union all
select * from task_084 union all
select * from task_085 union all
select * from task_086 union all
select * from task_087 union all
select * from task_088 union all
select * from task_089 union all
select * from task_090 union all
select * from task_091 union all
select * from task_092 union all
select * from task_093 union all
select * from task_094 union all
select * from task_095 union all
select * from task_096 union all
select * from task_097 union all
select * from task_098 union all
select * from task_099
) as t where t.business_no=’bizNo_201903151257512019031512575148987627′;

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

4条评论
  • Best SEO Service

    2020年1月28日 下午8:22

    Awesome post! Keep up the great work! 🙂

    1. jiukeshuju

      2020年2月23日 下午12:41

      THANKYOU!

  • AffiliateLabz

    2020年2月16日 下午2:52

    Great content! Super high-quality! Keep it up! 🙂

    1. jiukeshuju

      2020年2月23日 下午12:41

      THANKYOU!

发表评论

电子邮件地址不会被公开。 必填项已用*标注