zoukankan      html  css  js  c++  java
  • SQL组合查询

    组合查询:

    利用UNION,将多条SELECT语句的结果合并成一个一个结果集。

    比如:

    输入:

    要找到以下符合以下两个条件之一的顾客信息如cust_name,cust_contact,cust_email

    一:cust_state是‘IL’,‘IN’,‘MI’的。

    二:cust_name是‘Fun4all’的。 

    第一种解决方案   两个查询中加个UNION:

    SELECT cust_name,cust_contact,cust_email
    FROM Customers
    WHERE cust_state IN ('IL','IN','MI')
    UNION
    SELECT cust_name,cust_contact,cust_email
    FROM  Customers
    WHERE cust_name='Fun4ALL'

    第二种解决方案 使用WHERE:

    SELECT cust_name,cust_contact,cust_email
    FROM Customers
    WHERE cust_state IN ('IL','IN','MI')
    OR  cust_name='Fun4ALL'
  • 相关阅读:
    [BZOJ1584][Usaco2009 Mar]Cleaning Up 打扫卫生
    CSS浮动
    Django by example -----1总结
    C#函数重载
    linux目录的特点
    Linux调优
    linux
    对齐方式
    19-10-25-G-悲伤
    19-10-24-H
  • 原文地址:https://www.cnblogs.com/liuguangshou123/p/13944015.html
Copyright © 2011-2022 走看看