zoukankan      html  css  js  c++  java
  • 使用using关键字对连接进行简化

              在SQL/92标准可以使用USING子句对连接条件进行简化,但是只有在查询满足以下两个条件时才能给使用USING进行简化:

                   1、查询必须是等连接的

                   2、等连接中的列必须是同名

             如:商品表goods表和商品类型表category表中goods的外键和category的主键相同:categoryid而且是等连接,这里可以使用using

          select goodsname,categoryname
          from goods inner join category
          using(categoryid)

              在使用using是需要注意以下几个问题

                   1、在select子句中只能指定该列名,不能使用表名或别名

                   2、在using子句中也只能单独使用列名

              对于多与两个表的连接,先看这个例子

         select c.firstName,c.lastName,p.product_name ,pt.product_types_name 
         from customers c,purchase pr,products p,product_types pt
         where c.customer_id=pr.customer_id
         and p.products_id = pr.products_id
         and p.product_types_id=pt.product_types_id;

               使用using对上面的sql语句进行重写

         select c.first_name,c.last_name,p.products_name as product,pt.product_types_name as typesname
         from customers c inner join purchases pr
         using(customers_id)
         inner join products p
         using(products_id)
         inner join product_types pt
         using(product_types_id);



     

  • 相关阅读:
    striding layers 是什么意思?
    faster rcnn算法及源码及论文解析相关博客
    地铁客流中样本问题
    numpy
    Softmax 函数的特点和作用是什么?
    Faster RCNN代码理解(Python)
    卷积神经网络(CNN)学习笔记1:基础入门
    semantic segmentation 和instance segmentation
    基于深度学习的目标检测
    全卷积网络 FCN 详解
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3752248.html
Copyright © 2011-2022 走看看