SQL中查找某几个字段完全一样的数据

2023年 4月 20日 19.1k 0

有以下一个表 movestar(id,name,title,address),内容为: 现在要查找所有具有相同的title和address的人 复制代码 代码如下:select star1.name,star2.name,star1.title,star1.address from movestar as star1,movestar as

有以下一个表

movestar(id,name,title,address),内容为:

https://img.mryunwei.com/uploads/2023/04/20230420002716747.jpg

现在要查找所有具有相同的title和address的人

复制代码 代码如下:select star1.name,star2.name,star1.title,star1.address
from movestar as star1,movestar as star2
where star1.title = star2.title
    and star1.address = star2.address
    and star1.name < star2.name;

结果:

https://img.mryunwei.com/uploads/2023/04/20230420082719532.jpg

要点:使用了<,假如用<>则会将内容重复列出

以上就是SQL中查找某几个字段完全一样的数据的全部内容,希望能给大家一个参考,也希望大家多多支持每日运维。

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论