码迷,mamicode.com
首页 > 数据库 > 详细

mysql基础语句

时间:2016-01-07 10:20:29      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

1、多表查询(左连接)

SELECT a.*,b.*,b.id AS reid,c.*,c.id AS prid  FROM `1008_user` a LEFT JOIN `1008_reward` b ON a.id = b.uid LEFT JOIN `1008_prize` c ON c.id = b.rid   #外左连结

 2、夺标查询

SELECT us.*,re.*,re.id AS reid FROM `1008_reward` AS re,`1008_user` AS us WHERE re.uid = us.id   #内连结

 3关键词

select *,sum(pnum) as num from `1008_demo` group by pid order by num ASC|DESC

 

 

mysql基础语句

标签:

原文地址:http://www.cnblogs.com/finnlee/p/5108701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!