in 和子查询同时使用查不出来数据

old城 old城 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

一个很蛋疼的问题,如下,最后的结果查询不来,非常让人疑惑。

使用过程随机生成数据,我怀疑时类型问题,但是在创建中使用了cast和concat都没用,直接用in (98,91)之类的可以,但是用上子查询就查不出来 了

 create table query_test(
  stu_id varchar(20) primary key comment "学号",
  stu_name varchar(20) comment "姓名",
  stu_grade int comment "成绩"
 )
 ​
 delimiter $$
 create procedure auto_insert1()
 begin
    declare i int default 1;
    while (i<1000) do 
       insert into worker.query_test values (i,substr(md5(rand()*100),1,3),rand()*100);
       set i=i+1;
    end while;
 end $$
 delimiter ;
 ​
 call  auto_insert1();
 ​
 select * from query_test where stu_id in 
 (select group_concat(stu_id) from query_test group by stu_grade having stu_grade =100)  

 

 

...全文
评论 4
收藏 已收藏
分享
返回顶部
old城
MySQL 57,062 成员 56,759 内容