Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic mysql operations-removing duplicates, taking field names, query expressions, constants, etc., and the + sign

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

query constant value

SELECT 100; #Display constant values SELECT 'bitch';#Display string constants in single quotes

query expression

SELECT 100*99;SELECT 100%99;

query function

SELECT VERSION();

alias a field

SELECT 100*99 AS results; #Name the field as result, single quotation marks may be added, SELECT last_name AS last name,first_name AS name FROM employees may not be added; #Name multiple fields SELECT last_name AS last name FROM employees; #Method 2: Write field name SELECT last_name AS "out put" FROM employees directly without AS; #When field name contains keywords and special symbols, single/double quotation marks may be added

deduplication

Case: Query all department numbers involved in the employee table, remove the same number, add distinct

SELECT DISTINCT department_id FROM employees;

The + sign:

Only operator function, does not have string concatenation, when there is a string, it will convert the character type to the numerical type.

#As long as one side is null, the addition result must be null

SELECT NULL+10;

Case study: Employee first name and last name concatenated into one field and displayed as name

SELECT last_name+first_name AS Last name FROM employees;

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 298

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report