This article lists some of the work commonly used in SQL, to improve work efficiency.
1 Date format
Use DATE_FORMAT (get_date, '% Y-% m-% d') function formatted. Wherein: get_date fields that need to be formatted, '% Y-% m-% d' is formatted date format. E.g:
select date_format('1997-10-04 22:23:00','%y %M %b %D %W %a %Y-%m-%d %H:%i:%s %r %T');
结果:97 October Oct 4th Saturday Sat 1997-10-04 22:23:00 10:23:00 PM 22:23:00
SELECT count(*) FROM house Where get_date like '2006%-07%';
2 query whether there are duplicate records specified field
SELECT house_id, count(id) AS sumCount
FROM house
GROUP BY house_id HAVING sumCount > 1;
Here you can get all house_id have duplicate records, delete and update when we do these data processing such as the time, very easy.
3 Find more fields for duplicate records
select *
from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae
group by peopleId,seq having count(*) >
1)
Continuously updated, the next issue is more exciting.