标签:avg inner 记录 字段 price left join HERE sel str
Count()select avg(price) from book where bokk_author ="hhq"
子查询使用in
SELECT
*
FROM
book
WHERE
bokk_author IN (
SELECT
author_name
FROM
author
where author_name ="hhq"
)
子查询使用select子句
SELECT
*
FROM
book
WHERE
bokk_author = (
SELECT
author_name
FROM
author
LIMIT 1, 1
)
内连接
把两个表符合条件的数据筛选出来合并成一个表,包含两个表的字段
select *
FROM
author a
INNER JOIN book b ON a.author_name = b.bokk_author;
SELECT
a.*,b.book_name
FROM
author a
INNER JOIN book b ON a.author_name = b.bokk_author
左连接
把两个表符合条件记录筛选出来合并成一个表展示,以左表为准,如果连接的表没有数据,展示为空;
SELECT
*
FROM
author a
LEFT JOIN book b ON a.author_name = b.bokk_author
右连接
把两个表符合条件记录筛选出来合并成一个表展示,以右表为准,如果连接的表没有数据,展示为空;
SELECT
*
from author a
right join book b on a.author_name = b.bokk_author
标签:avg inner 记录 字段 price left join HERE sel str
原文地址:http://blog.51cto.com/13496943/2145176