zoukankan      html  css  js  c++  java
  • 第四章 过滤

    1.基本描述

        本章主要讲解在SELECT、UPDATE、DELETE语句中的WHERE子句所能使用的各种类型的过滤条件。

    2.基本样例

    SELECT pt.name product_type, p.name product FROM product p INNER JOIN product_type pt
    ON p.product_type_cd = pt.product_type_cd WHERE pt.name = 'Customer Accounts';
    
    SELECT pt.name product_type, p.name product FROM product p INNER JOIN product_type pt
    ON p.product_type_cd = pt.product_type_cd WHERE pt.name <> "Customer Accounts";
    
    SELECT emp_id, fname, lname, start_date FROM employee 
    WHERE start_date < '2007-01-01';
    
    SELECT emp_id, fname, lname, start_date FROM employee
    WHERE start_date < '2007-01-01' AND start_date >= '2005-01-01';
    
    SELECT emp_id, fname, lname, start_date FROM employee 
    WHERE start_date BETWEEN '2005-10-01' AND '2007-01-01';
    
    SELECT emp_id, fname, lname, start_date FROM employee
    WHERE start_date BETWEEN '2007-01-01' AND '2005-01-01';
    
    SELECT emp_id, fname, lname, start_date FROM employee
    WHERE start_date >= '2007-01-01' AND start_date <= '2005-01-01';
    
    SELECT emp_id, fname, lname, start_date FROM employee 
    WHERE start_date >= '2007-01-01' AND start_date <= '2005-01-01';
    
    SELECT account_id, product_cd, cust_id, avail_balance FROM account
    WHERE avail_balance BETWEEN 3000 AND 5000;
    
    SELECT cust_id, fed_id FROM customer WHERE cust_type_cd = 'I'
    AND fed_id BETWEEN '50-00-0000' AND '999-99-9999';
    
    SELECT account_id, product_cd, cust_id, avail_balance FROM account
    WHERE product_cd = 'CHK' OR product_cd = 'SAV'
    OR product_cd = 'CD' OR product_cd = 'MM';
    
    SELECT account_id, product_cd, cust_id, avail_balance FROM account
    WHERE product_cd IN ('CK', 'SAV', 'CD', 'MM');
    
    SELECT account_id, product_cd, cust_id, avail_balance FROM account
    WHERE product_cd IN (SELECT product_cd FROM product WHERE product_type_cd = 'ACCOUNT');
    
    SELECT account_id, product_cd, cust_id, avail_balance FROM account 
    WHERE product_cd NOT IN ('CHK', 'SAV', 'CD', 'MM');
    
    #SELECT emp_id, fname, lname, FROM employee WHERE LEFT(lname, 1) = 'T';
    
    SELECT lname FROM employee WHERE lname LIKE '_a%e%';
    
    SELECT cust_id, fed_id FROM customer WHERE fed_id LIKE '___-__-___';
    
    SELECT emp_id, fname, lname FROM employee WHERE lname LIKE 'F%' OR lname LIKE 'G%';
    
    SELECT emp_id, fname, lname FROM employee WHERE lname REGEXP '^[FG]';
    
    SELECT emp_id, fname, lname, superior_emp_id FROM employee WHERE superior_emp_id IS NULL;
    
    SELECT emp_id, fname, lname, superior_emp_id FROM employee WHERE superior_emp_id = NULL;
    
    SELECT emp_id, fname, lname, superior_emp_id FROM employee WHERE superior_emp_id IS NOT NULL;
    
    SELECT emp_id, fname, lname, superior_emp_id FROM employee WHERE superior_emp_id != 6;
    
    SELECT emp_id, fname, lname, superior_emp_id FROM employee 
    WHERE superior_emp_id != 6 OR superior_emp_id IS NULL;
    
  • 相关阅读:
    关于网购心态
    c++ In STL maps, is it better to use map::insert than []? Stack Overflow
    小工具:sshcopyid_老王的技术手册 ( 我的新博客:http://huoding.com )_百度空间
    djangoqbe
    C++ STL map的使用
    容器find_if函数定义和其第三个参数重载的疑问
    ArchLinux的安装与配置
    使用Grub进行Linux的硬盘安装与修复
    MySQL数据类型简介
    ArchLinux下Alsa的简单配置
  • 原文地址:https://www.cnblogs.com/LuckPsyduck/p/12608202.html
Copyright © 2011-2022 走看看