Mysql 中联接SQL语句中,ON子句的语法格式为:table1.column_name = table2.column_name。
当模式设计对联接表的列采用了相同的命名样式时,就可以使用 USING 语法来简化 ON 语法,格式为:USING(column_name)。
例如:
  1. [sql]
  2. SELECT f.color, c.is_primary, c.is_dark, c.is_rainbow
  3. FROM flags f    www.2cto.com
  4. INNER JOIN color c ON f.color = c.color
  5. WHERE f.country = 'China';
等价于
    1. [sql]
    2. SELECT f.color, c.is_primary, c.is_dark, c.is_rainbow
    3. FROM flags f
    4. INNER JOIN color c USING(color)
    5. WHERE f.country = 'China';

sql中用JOIN USING 简化JOIN ON的更多相关文章

  1. SQL的JOIN语法解析(inner join, left join, right join, full outer join的区别)

    原文链接:http://www.powerxing.com/sql-join/ 总的来说,四种JOIN的使用/区别可以描述为: left join 会从左表(shop)那里返回所有的记录,即使在右表( ...

  2. SQL Left Join, Right Join, Inner Join, and Natural Join 各种Join小结

    在SQL语言中,存在着各种Join,有Left Join, Right Join, Inner Join, and Natural Join等,对于初学者来说肯定一头雾水,都是神马跟神马啊,它们之间到 ...

  3. sql语法:inner join on, left join on, right join on详细使用方法

    inner join(等值连接) 只返回两个表中联结字段相等的行 left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有 ...

  4. sql之left join、right join、inner join的区别

    sql之left join.right join.inner join的区别 left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括 ...

  5. SQL中inner join、outer join和cross join的区别

    对于SQL中inner join.outer join和cross join的区别简介:现有两张表,Table A 是左边的表.Table B 是右边的表.其各有四条记录,其中有两条记录name是相同 ...

  6. SQL表连接查询(inner join、full join、left join、right join)

    SQL表连接查询(inner join.full join.left join.right join) 前提条件:假设有两个表,一个是学生表,一个是学生成绩表. 表的数据有: 一.内连接-inner ...

  7. SQL的inner join、left join、right join、full outer join、union、union all

    主题: SQL的inner join.left join.right join.full outer join.union.union all的学习. Table A和Table B表如下所示: 表A ...

  8. 图解SQL的inner join、left join、right join、full outer join、union、union all的区别

    SQL的Join语法有很多,inner join(等值连接) 只返回两个表中联结字段相等的行,left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录,right join(右 ...

  9. sql多表查询(out join,inner join, left join, right join)

    left join以左表为基准显示所有左表的信息,在on中有符合条件的其他表也显示出来 right join则相反 inner join的只显示on中符合条件的 1 使用多个表格 在「world」资料 ...

随机推荐

  1. LeetCode -- Valid Parenthese

    Question: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine i ...

  2. [洛谷P1972][SDOI2009]HH的项链

    题目大意:给你一串数字,多次询问区间内数字的种类数 题解:莫队 卡点:洛谷数据加强,开了个$O(2)$ C++ Code: #include <cstdio> #include <a ...

  3. hdu 4388 Stone Game II sg函数 博弈

    Stone Game II comes. It needs two players to play this game. There are some piles of stones on the d ...

  4. delete zone and cfgsave on brocade by CMD

    brocade:user> cfgshowDefined configuration: cfg: cfg001 AMS_ESX_HBA1; AMS_ESX_HBA2; HUS_ESX_HBA1; ...

  5. web本地存储 sessionStorage 和 localStorage

    1.sessionStorage  临时存储 为每一个数据源维持一个存储区域,在浏览器打开期间存在,包括页面重新加载. 2.localStorage 长期存储 与sessionStorage一样,但在 ...

  6. Fiddler抓取HTTP请求

    参考链接:http://blog.csdn.net/ohmygirl/article/details/17849983/ http://www.cnblogs.com/kingwolf_JavaScr ...

  7. linq使用 count与sum等

    using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; us ...

  8. vue 项目 webstrom IDE格式化代码规则遵循eslint设置

    首先vue-cli生成了一个项目,开启了eslint的检测, 但是根据webstorm的快捷格式化代码 ctrl+alt+L会造成eslint报错. 解决办法一: 编辑器打开文件 首先,在编辑器里面要 ...

  9. 2018多校第三场 hdu6331 M :Walking Plan

    题目链接 hdu6331 自我吐槽,这场多校大失败,开局签到因输入输出格式写错,wa了3发.队友C题wa了1个小时,还硬说自己写的没错,结果我随便造了个小数据,他都没跑对.然后跑对了后又进入了无限的卡 ...

  10. pymongo.errors.BulkWriteError错误排解

    在mongodb进行数据库操作的时候触发异常   pymongo Error: pymongo.errors.BulkWriteError: batch op errors occurred 这种问题 ...