
`test2`表
- 1.
select * from table的本质其实是因为table里面有数据,我们此处的*可以是table表里面的任何数据 - 2.如果我们需要查询
table2里面的所有数据,一般是select * from test2 - 3.其实也可以这样
select * from (select * from test2) as tmp切记,此处必须给(select * from test2)一个别名。他本质相当于是一个表名。 - 4.那么我们要查询某个字段值,可以如下图所示
select id,intfrom (select * from test2) as tmp - 5.如果要查询的某个字段是关键字,比如此处的
(int)我们可以用键盘左上角的按个单引号``引起来

图片.png
如果需要从多个表中的数据取值,然后对这些值做查询处理,可以按照以下语法
select * from (
select min(price) as price ,commodity_id from mall_sku group by commodity_id
union all
select price as price,commodity_id from mall_commodity where is_sku=0 group by commodity_id
) as temp_table order by price
- 需要注意的是内部多个
sql查询字段的顺序必须保持一致
sql查询
