查询表内容
格式:select * from 库名.表名
命令:select * from address_area
条件查询
查看石家庄市的
命令:select * from address_area where cityname='石家庄市'
查看石家庄市的有多少个
命令:select count(id) from address_area where cityname='石家庄市'
双表联合查询
内连接:inner join
命令:select * from ex_kehubiao_90 a inner join ex_kehubiao_95 b on a.客户姓名=b.客户姓名
左连接:left join
命令:select a.客户姓名,a.客户编号,b.联系电话 from ex_kehubiao_90 a left join ex_kehubiao_95 b on a.客户姓名=b.客户姓名
右连接:right join
命令:select a.id,a.客户姓名,a.客户编号,b.联系电话 from ex_kehubiao_90 a right join ex_kehubiao_95 b on a.`客户编号`=b.`客户编号`
查看某物品数量
命令:select 名称,sum(数量) as "数量" from ex_gudingzichan_95 group by 名称
统计出来这两列有多少条
命令:select count(name),count(cityname) from address_area
将空值返回0用如下语句:select ifnull(字段名,0) from 表名;
命令:select ifnull(数量,0) from ex_gudingzichan_95