SQL语句集锦

携带条件连表子查询(条件查询表b后的结果用来查询表a):
SELECT
        a.* FROM 表a AS a INNER JOIN (
                SELECT * FROM 表b WHERE 条件字段='条件值')
                     AS b ON
                         b.company_id = a.company_id
                             WHERE 表a字段='条件'
连表子查询(根据表b查询表a):
SELECT
     * from 表a
         INNER JOIN 表b On 表b字段=表a字段

你可能感兴趣的:(SQL语句集锦)