MYSQL 的二次查询怎么写?
时间:2011-10-20
来源:互联网
title code
123 456
123 789
444 012
1 先查出 code=456
2 再查出 code=456 的title 的值
3 根据2查询出的title值 最後查出 表test 中所有title 和code 值
作者: tianya2297360 发布时间: 2011-10-20
select title,code from test where code = '456';
这个就可以获得所有的code为456 的title了。
select * from test;
这个可以获得所有的title和code
作者: ohmygirl 发布时间: 2011-10-20
作者: cpc1984 发布时间: 2011-10-20
作者: chendong_j 发布时间: 2011-10-20
select title,code from test where title = (select title from test where code = '456');
你这是完全多余的子查询。
作者: ohmygirl 发布时间: 2011-10-20
查询不出来
作者: tianya2297360 发布时间: 2011-10-20
正解
作者: tianya2297360 发布时间: 2011-10-20
select title,code from test where title = (select title from test where code = '456');
正解
是正解么?
如果有多个code = 456 的,那么用=还对么?即使用子查询也要用.
select title,code from test where title in (select title from test where code = '456');
作者: ohmygirl 发布时间: 2011-10-20
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28