博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 自联结
阅读量:4962 次
发布时间:2019-06-12

本文共 1433 字,大约阅读时间需要 4 分钟。

 

mysql> select * from test;+----+------------+-------+-----------+| id | name       | score | subject   |+----+------------+-------+-----------+|  1 | xiaoming   |    89 | shuxue    ||  2 | xiaohong   |    89 | shuxue    ||  3 | xiaohong   |    80 | english   ||  4 | xiaohong   |    80 | physics   ||  5 | xiaohong   |    80 | astronaut ||  6 | xiaoming   |    80 | physics   ||  7 | xiaoming   |    80 | astronaut ||  8 | xiaoming   |    80 | english   ||  9 | xiaobai    |    80 | astronaut || 10 | 1.2xiaobai |    80 | english   || 11 | 2.2xiaobai |    80 | physics   || 12 | 3xiaobai   |    80 | shuxue    || 13 | 123xiaohei |    80 | astronaut || 14 | xiaohei    |    80 | shuxue    || 15 | xiaohei    |    80 | physics   || 16 | .12xiaohei |    80 | english   |+----+------------+-------+-----------+16 rows in set (0.00 sec)mysql> select * from test where name in (select name from test where score=89);+----+----------+-------+-----------+| id | name     | score | subject   |+----+----------+-------+-----------+|  1 | xiaoming |    89 | shuxue    ||  2 | xiaohong |    89 | shuxue    ||  3 | xiaohong |    80 | english   ||  4 | xiaohong |    80 | physics   ||  5 | xiaohong |    80 | astronaut ||  6 | xiaoming |    80 | physics   ||  7 | xiaoming |    80 | astronaut ||  8 | xiaoming |    80 | english   |+----+----------+-------+-----------+8 rows in set (0.01 sec)

 

 

 

转载于:https://www.cnblogs.com/sea-stream/p/11312660.html

你可能感兴趣的文章
《PHP字符串函数》笔记
查看>>
android studio 编译NDK android studio 生成.so文件
查看>>
场景调研
查看>>
DICOM image viewers
查看>>
css清除浮动clearfix:after的用法详解(转)
查看>>
可以在浏览器中在线编辑office文件的扩展程序汇总
查看>>
程序员工资一般多少
查看>>
2018.4.22
查看>>
iOS开发之多媒体API(1)
查看>>
让iOS应用支持不同版本的系统与设备
查看>>
日期 function
查看>>
Java 连接池的工作原理
查看>>
poj1970 The Game(DFS)
查看>>
poj1040 Transportation(DFS)
查看>>
ubuntu16.04编译安装mysql5.7
查看>>
JavaScript面向对象之对象的声明、遍历和存储
查看>>
H5离线缓存
查看>>
python&数据分析&数据挖掘--参考资料推荐书籍
查看>>
NODE.JS学习的常见误区及四大名著
查看>>
求第区间第k大数 TLE归并树
查看>>