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

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

 

mysql> select * from user;+------+----------+-----------+| id   | name     | address   |+------+----------+-----------+|    1 | xiaoming | beijing   ||    2 | xiaobai  | shandong  ||    3 | xiaohong | suzhou    ||    4 | xiaohei  | changchun |+------+----------+-----------+4 rows in set (0.00 sec)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 user inner join test on test.subject="shuxue" and user.name=test.name;+------+----------+-----------+----+----------+-------+---------+| id   | name     | address   | id | name     | score | subject |+------+----------+-----------+----+----------+-------+---------+|    1 | xiaoming | beijing   |  1 | xiaoming |    89 | shuxue  ||    3 | xiaohong | suzhou    |  2 | xiaohong |    89 | shuxue  ||    4 | xiaohei  | changchun | 14 | xiaohei  |    80 | shuxue  |+------+----------+-----------+----+----------+-------+---------+3 rows in set (0.00 sec)mysql> select * from user,test where test.name=user.name and test.subject="shuxue";+------+----------+-----------+----+----------+-------+---------+| id   | name     | address   | id | name     | score | subject |+------+----------+-----------+----+----------+-------+---------+|    1 | xiaoming | beijing   |  1 | xiaoming |    89 | shuxue  ||    3 | xiaohong | suzhou    |  2 | xiaohong |    89 | shuxue  ||    4 | xiaohei  | changchun | 14 | xiaohei  |    80 | shuxue  |+------+----------+-----------+----+----------+-------+---------+3 rows in set (0.00 sec)mysql> select * from user,test where test.subject="shuxue" and test.name=user.name;+------+----------+-----------+----+----------+-------+---------+| id   | name     | address   | id | name     | score | subject |+------+----------+-----------+----+----------+-------+---------+|    1 | xiaoming | beijing   |  1 | xiaoming |    89 | shuxue  ||    3 | xiaohong | suzhou    |  2 | xiaohong |    89 | shuxue  ||    4 | xiaohei  | changchun | 14 | xiaohei  |    80 | shuxue  |+------+----------+-----------+----+----------+-------+---------+3 rows in set (0.00 sec)

 

 

 

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

你可能感兴趣的文章
开源的 Restful Api 集成测试工具 Hitchhiker
查看>>
人工智能时代架构设计还有没有价值
查看>>
炼数成金数据分析课程---18、降维技术(后面要重点看)
查看>>
普通广播接收者和有序广播接收者
查看>>
html5--6-19 CSS3中的文字与字体
查看>>
第三百七十五节,Django+Xadmin打造上线标准的在线教育平台—创建课程机构app,在models.py文件生成3张表,城市表、课程机构表、讲师表...
查看>>
查找两个数组的相同字符(两个超大文件的相同字符)
查看>>
POJ 1236 Network of Schools(tarjan)题解
查看>>
SensorService architechure’ note
查看>>
基于ASP.NET MVC(C#)和Quartz.Net组件实现的定时执行任务调度
查看>>
分布式之数据库和缓存双写一致性方案解析
查看>>
as运算符
查看>>
[转载]Request、Request.Form和Request.QueryString的区别
查看>>
JVM异常退出
查看>>
百度“搜索设置”之关于在页面定位某元素,而其中又参杂动态页面存在的问题解决方法...
查看>>
简单深拷贝
查看>>
《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #20 使用fio进行I/O的基准测试...
查看>>
Google 视频编码格式 VP9 究竟厉害在哪里
查看>>
console给你份兼职!!!
查看>>
Win7下打开计算机管理时出现错误的解决办法
查看>>