MySQL (非存储过程)解决易语言难题
发布时间:2020-05-23 07:18:04 所属栏目:MySql 来源:互联网
导读:MySQL (非存储过程)解决易语言难题
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 drop table if exists n1;
create temporary table n1(num int (1));
insert into n1 values(1),(2),(3),(4),(5),(6),(7),(8),(9);
drop table if exists n2;
create temporary table n2
select * from n1;
drop table if exists n3;
create temporary table n3
select * from n1;
drop table if exists nums1;
create temporary table nums1
select n1.num * 100 + n2.num * 10 + n3.num as num
from n1 left join n2
on n1.num <> n2.num
left join n3
on n1.num <> n3.num and n2.num <> n3.num;
drop table if exists nums2;
create temporary table nums2
select * from nums1;
drop table if exists nums3;
create temporary table nums3
select * from nums1;
select *
from nums1 as n1 left join nums2 as n2
on n1.num <> n2.num
left join nums3 as n3
on n1.num <> n3.num and n2.num <> n3.num
where n1.num * 2 = n2.num and n1.num * 3 = n3.num
and n1.num not rlike concat("[",n2.num,"]")
and n1.num not rlike concat("[",n3.num,"]")
and n2.num not rlike concat("[","]");
drop table if exists n1;
drop table if exists n2;
drop table if exists n3;
drop table if exists nums1;
drop table if exists nums2;
drop table if exists nums3;
结果:
mysql> select *
-> from nums1 as n1 left join nums2 as n2
-> on n1.num <> n2.num
-> left join nums3 as n3
-> on n1.num <> n3.num and n2.num <> n3.num
-> where n1.num * 2 = n2.num and n1.num * 3 = n3.num
-> and n1.num not rlike concat("[","]")
-> and n1.num not rlike concat("[","]")
-> and n2.num not rlike concat("[","]");
+------+------+------+
| num | num | num |
+------+------+------+
| 192 | 384 | 576 |
| 219 | 438 | 657 |
| 273 | 546 | 819 |
| 327 | 654 | 981 |
+------+------+------+
4 rows in set (0.03 sec)
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
