CREATE TABLE num_t
(
num
varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE range_t
(
maxn
varchar(255) DEFAULT NULL,
minn
varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
格式变得有点难看。。见谅。。我想生成一张新表,表结构是这两个综合在一起的,数据要求就是 num 在 maxn 和 minn 的范围内。
select b.maxn,b.minn from (select num from num_t) a join (select maxn,minn from range_t) b on cast(a.num as signed)>=cast(b.minn as signed) and cast(a.num as signed)<=cast(b.maxn as signed);
我的这个 sql 执行结果是空,估计是因为 on 后面的不等值连接问题。。。大佬们有没有好的办法可以完成我想要的表?
1
keepeye 2020-12-09 16:41:24 +08:00 1
|
2
shijia 2020-12-09 16:53:55 +08:00
```sql
select * from num_t, range_t where num_t.nm>=range_t.minn and num_t.nm<=range_t.maxn ``` 酱紫? |