首页 > 其他分享 >基本的select语句

基本的select语句

时间:2023-02-18 17:12:13浏览次数:28  
标签:语句 基本 salary employees employee null id select

1. 最基本的select语句

select 1+1,3*2;

*:表中所有的字段(或者列)

select * from employees;

选择特定的列

select employee_id,last_name,salary from employees;

2.列的别名

as:全称:alias(别名)可以省略
列的别名可以使用一对""引起来,不要使用''
select employee_id emp_id,last_name AS lname,department_id from employees;

3.去除重复行

查询员工表中一共有哪些部门id
select DISTINCT department_id from employees;

4.空值参与运算:结果一定也为null

空值:null 不等同于0,'','null'
select employee_id,salary "月工资",salary*(1+commission_poct)\*12 "年工资" from employees;
引入IFNULL
select employee_id,salary "月工资",salary*(1+IFNULL(0commission_poct,0)\*12 "年工资" from employees;

5.着重号 ``

select * from order
遇到关键字作为表命数据库名等 用 `` 包裹order 即可解决

6.查询常数

select 123,employee_id,last_name from employees;

7.显示表结构

显示表中字段的详细信息:describe employees;DESC employee

标签:语句,基本,salary,employees,employee,null,id,select
From: https://www.cnblogs.com/rhy2103/p/17133060.html

相关文章

  • linux基本功系列之fdisk命令实战
    前言大家好,又见面了,我是沐风晓月,本文是专栏【linux基本功-基础命令实战】的第49篇文章。......
  • 【Java-01】java基础-基本语法
    1、基本输出语句/**java*多行注释*///java单行注释publicclass_01_HelloWorld{publicstaticvoidmain(String[]args){//main方法System.......
  • Redis的五大基本类型
    String List有序可重复trim:通过截取之后,保留的是截取到的元素 rpoplpush:移除一个列表的值并将移除的值push进目标列表 lset:将列表指定下标的值替换,相当于......
  • vue2 - router 的基本使用,安装router,配置router,router 标签
    1.安装routernpminstallvue-router 2.定义router路由导航src/router/index.jsimportVuefrom"vue";importVueRouterfrom"vue-router";//引入组件import......
  • 打断语句
    Break语句Break语句用于跳出循环,当一个循环没有达到循环结束的条件并要结束循环时,使用Break语句。functionGetValue:integer;vari,j:integer;begini:=0;for......
  • c++ 11 lamda 如何实现 linq 中 先 where 再 select 的功能
    面向AI编程,回答如下:在C++11中,可以使用lambda表达式和算法库中的std::copy_if和std::transform算法来实现LINQ中先where再select的功能。具体来说,可以先使用......
  • 基本的Dos命令
    打开CMD的方式1、开始+系统+命令提示符2、window+R输入cmd打开控制台3、在任意的文件夹下面,按住Shift+鼠标右键点击,在此处打开命令行窗口4、资源管理器的地址栏前面加上c......
  • document.onselectstart
    在网页中拖动时,会引起某些文字或一些内容被选中,导致网页中蓝蓝的一片,视觉效果很差,所以我加了个document.onselectstart=function(){returnfalse;}这样子,拖动时网页中的内......
  • python学习笔记一:基本数据类型
    1、python的一切都是对象,对象是包含属性和方法的一个整体。2、数据类型的组成:身份(内存地址,通过id方法可看它的唯一标识符);类型(通过type方法查看);值(数据项)3、常用基本数据类型......
  • yii2 中 linslin\Curl的基本使用
     yii2中linslin\Curl的基本使用一、get请求:1.1简单get请求uselinslin\yii2\curl;$curl=newcurl\Curl();//gethttp://example.com/get请求改网址$response=$curl......