8

MYSQL_02--多表查询select

 1 year ago
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.
neoserver,ios ssh client

MYSQL_02--多表查询select

精选 原创

月同学不写Bug 2022-11-25 13:01:17 博主文章分类:MYSQL ©著作权

文章标签 字段名 插入图片 sql 文章分类 MySQL 数据库 私藏项目实操分享 阅读数237

1. 基本语法

select 字段名1,字段名2… from 表1,表2…表n;  # 不带条件,对多表查询字段进行排列组合
select 字段名1,字段名2… from 表1,表2…表n where 条件;  # 带条件,只会查询到满足条件的值

2. 举例说明

2.1 建表

有两个表,分别为:
dept:
MYSQL_02--多表查询select_sql
demo:
MYSQL_02--多表查询select_字段名_02

2.2 查询

SELECT d.realname, t.dname FROM demo as d, dept AS t # 不带条件,对多表查询字段进行排列组合

查询结果:
MYSQL_02--多表查询select_字段名_03

SELECT d.realname, t.dname FROM demo as d, dept AS t WHERE d.loc = t.loc # 带条件,只会查询到满足条件的值

查询结果:
MYSQL_02--多表查询select_sql_04

  • 1收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK