Php checks whether a database field is a unique order Database id & nbsp; dan & nbsp; & nbsp; money01 & nbsp; 0001a & nbsp; 502 & nbsp; 0001a & nbsp; 503 & nbsp; 0001a & nbsp php how to check whether a database field is unique
Order database
Id dan money
01 0001a 5
02 0001a 5
03 0001a 5
04 0001b 5
05 0001c 5
How can I check whether an order number is duplicated?
If all data is listed
For example, the upper column
List
01 0001a 5
02 0001a 5
03 0001a 5
How do I write mysql statements?
------ Solution --------------------
Select * from tt t where exists (select 1 from tt where dan = t. dan and id! = T. id );
------ Solution --------------------
It should be about the database: oracle: select * from t where dan in (select dan from t where having count (dan)> 1 group by dan ).
------ Solution --------------------
Select id, dan, money, count (*) as num from ssc_record group by dan having num> 1