MYSQL很好的SQL语句_MySQL
bitsCN.com
MYSQL很好的SQL语句
MYSQL-
1.将查询结果中的0/1分别显示女/男SELECT CASE sexWHEN 1 THEN '男'WHEN 0 THEN '女'ELSE '不确定'ENDFROM carsystem.user2.删除表的一列alter table TEST_USER drop column age3.只更新当天登陆的民警的退出时间Update policemenlogin set quitdate=now() WHERE policemenId='p4' and to_days(logindate)8to_days(now())4.查过去24小时之内的数据(一下内容参见另一篇文章:2013.10.13 事务特性、MYSQL 触发器、存储过程、函数)核心:checkDate >DATE_ADD(now(), INTERVAL -1 DAY)String sql = "select * from records where vehicleId='" + vehicleId+ "' and checkDate >DATE_ADD(now(), INTERVAL -1 DAY)"+ " order by checkDate DESC";DATE_ADD(now(),INTERVAL -1 DAY);系统函数,指当前时间减去1天,即过去24小时时间段内5.按天数统计数据数量SELECT COUNT(*),records.checkdate FROM records GROUP BY TO_DAYS(records.checkdate);6.按月份统计数据数量SELECT COUNT(*),records.checkdate FROM records GROUP BY MONTH(records.checkdate);7.获取当天数据select * from policemenlogin where DATE_FORMAT(logindate,'%Y-%m-%d')=CURDATE();//取当天数据8.按月份分组SELECT DATE_FORMAT(time,'%Y%m') t,COUNT(*) '数量' FROM `user` GROUP BY PERIOD_DIFF( t,'200001');PERIOD_DIFF( t,'200001');//返回2000年01月到t时间的总月份数
bitsCN.com

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

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
