8
MYSQL_02--多表查询select
source link: https://blog.51cto.com/husheng/5886445
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
MYSQL_02--多表查询select
精选 原创1. 基本语法
select 字段名1,字段名2… from 表1,表2…表n; # 不带条件,对多表查询字段进行排列组合
select 字段名1,字段名2… from 表1,表2…表n where 条件; # 带条件,只会查询到满足条件的值
2. 举例说明
2.1 建表
有两个表,分别为:
dept:
demo:
2.2 查询
SELECT d.realname, t.dname FROM demo as d, dept AS t # 不带条件,对多表查询字段进行排列组合
查询结果:
SELECT d.realname, t.dname FROM demo as d, dept AS t WHERE d.loc = t.loc # 带条件,只会查询到满足条件的值
查询结果:
- 赞
- 1收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK