PHP学习之SQL语句快速入门

 更新时间:2010年03月23日 22:46:57   作者:  
在学校php过程中,需要用得到的一些语句。比较简单的大家一定要掌握啊。
Select * from tablename
SQL> select * from employees;
Select select list from tablename
SQL> select employee_id,first_name from employees;
Select distinct … from tablename
SQL> select distinct manager_id from employees;
||连接符使用以及 加减乘除以及括号的使用
SQL> select employee_id,first_name||'.'||last_name,salary*(1+0.1)/100,manager_id
2 from employees;
+-做正负号使用
SQL> select -salary from employees;
<>,>,<,=,!=等比较操作符
SQL> select * from employees where salary >13000;
SQL> select * from employees where salary <13000;
SQL> select * from employees where salary <>13000;
SQL> select * from employees where salary =13000;
In
SQL> select -salary from employees where employee_id in (100,101,102);
SQL> select -salary from employees where employee_id in (select employee_id from employees);
not in
SQL> select -salary from employees where employee_id not in (100,101,102);
Any(比任意一个都)
select * from employees where employee_id >any(100,101,102);
some 是 SQL-92 标准的 any 的等效物
select * from employees where employee_id >any(100,101,102);
all(比所有的都)
select * from employees where employee_id >all(100,101,102);
between and
select * from employees where employee_id between 100 and 102;
not between and
select * from employees where employee_id not between 100 and 102;
逻辑操作符
And 和 or
select * from employees where employee_id > 100 and employee_id < 1000;
select * from employees where employee_id > 100 or employee_id < 1000;
Order by
Desc
select * from employees where employee_id between 100 and 102 order by employee_id desc;
Asc
select * from employees where employee_id between 100 and 102 order by employee_id asc;
dual哑元表没有表需要查询的时候可以用它
select sysdate from dual;
select 1*2*3*4*5 from dual;

相关文章

  • MySQL学习之数据库表五大约束详解小白篇

    MySQL学习之数据库表五大约束详解小白篇

    本篇文章非常适合MySQl初学者,主要讲解了MySQL数据库的五大约束及约束概念和分类,有需要的朋友可以借鉴参考下,希望可以有所帮助
    2021-09-09
  • SQL查询至少连续七天下单的用户

    SQL查询至少连续七天下单的用户

    这篇文章介绍了SQL查询至少连续七天下单用户的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-01-01
  • mysql 5.7.18 安装教程及问题汇总

    mysql 5.7.18 安装教程及问题汇总

    这篇文章主要介绍了mysql 5.7.18 安装教程及问题汇总,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2017-04-04
  • mysql 5.6 压缩包版安装方法

    mysql 5.6 压缩包版安装方法

    这篇文章主要为大家详细介绍了mysql 5.6 压缩包版安装方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-12-12
  • MySQL事务的隔离性是如何实现的

    MySQL事务的隔离性是如何实现的

    最近做了一些分布式事务的项目,对事务的隔离性有了更深的认识,后续写文章聊分布式事务。今天就复盘一下单机事务的隔离性是如何实现的?感兴趣的可以了解一下-
    2021-09-09
  • mysql zip archive 版本(5.7.19)安装教程详细介绍

    mysql zip archive 版本(5.7.19)安装教程详细介绍

    这篇文章主要介绍了mysql zip archive 版本(5.7.19)安装教程详细介绍,需要的朋友可以参考下
    2017-10-10
  • MySQL时区查看及设置全过程

    MySQL时区查看及设置全过程

    在服务器环境下,MySQL默认时区可能是UTC,需注意应用时区设置,若查询条件使用Now()/sysdate(),会根据MySQL时区查询,导致时间错乱,可使用`selectnow()`检查时间准确性,查看和修改MySQL时区的方法包括使用命令和修改配置文件
    2025-01-01
  • MySQL最大连接数max_connections设置的两种方法

    MySQL最大连接数max_connections设置的两种方法

    MySQL的最大连接数可以通过两种方法进行设置,通过命令行临时修改和通过配置文件永久修改这两种方法,本文将通过代码示例给大家详细的讲解一下这两种方法,需要的朋友可以参考下
    2024-05-05
  • MySQL数据库操作的基本命令

    MySQL数据库操作的基本命令

    这篇文章主要介绍了MySQL使用初步之MySQL数据库的基本命令,需要的朋友可以参考下
    2017-05-05
  • MYSQL的存储过程和函数简单写法

    MYSQL的存储过程和函数简单写法

    简单的说,就是一组SQL语句集,功能强大,可以实现一些比较复杂的逻辑功能,类似于JAVA语言中的方法,这里就为大家简单介绍一下,需要的朋友可以参考下
    2018-05-05

最新评论