php 如何检测一个数据库字段是否是唯一的
订单数据库
id dan money
01 0001a 5
02 0001a 5
03 0001a 5
04 0001b 5
05 0001c 5
如何检测一个订单号是否是有重复的
如果有列出所有数据
如上列
列出
01 0001a 5
02 0001a 5
03 0001a 5
mysql语句该怎么写?
回复讨论(解决方案)
select * from tt t where exists (select 1 from tt where dan=t.dan and id !=t.id);
应该是关于数据库的问题:oracle:select * from t where dan in (select dan from t where having count(dan)>1 group by dan)。
恩,SELECT * from ssc_record WHERE types = 7 and dan1 in(SELECT dan1 from ssc_record GROUP BY dan1 HAVING count(1)>2)
这样查询起来好慢阿 数据量大就卡在那不会动了。
select id,dan,money,count(*) as num from ssc_record group by dan having num > 1

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
