select count(*),t1.`name` from test_id t1INNER JOIN test_id t2on t1.id >= t2.idgroup by t1.id,t1.`name`HAVING count(*) < t1.idorder by t1.idlimit 1;se...
分类:
数据库 时间:
2014-12-16 13:28:14
阅读次数:
261
对列表排序a=[1,2,3,4,5]printa.sort()2.给你一个字符串a,如a=‘12345’,对a进行逆序输出a。printa[::-1]3.给你一字典a,如a={1:1,2:2,3:3},输出字典a的key,以‘,‘链接,如‘1,2,3‘。print‘,‘.join([str(i)foriina.keys()])或者b=list(a.keys())foriinrange(len(b)): b[i]=s..
分类:
编程语言 时间:
2014-12-15 22:05:11
阅读次数:
198
之前我们看到的左连接 (left join),又称内部连接 (inner join)。在这个情况下,要两个表格内都有同样的值,那一笔资料才会被选出。那如果我们想要列出一个表格中每一笔的资料,无论它的值在另一个表格中有没有出现,那该怎么办呢?在这个时候,我们就需要用到 SQL OUTER JOIN(外部连接) 的指令。
外部连接的语法是依数据库的不同而有所不同的。举例来说,在 Oracle 上,我...
分类:
数据库 时间:
2014-12-15 19:10:26
阅读次数:
219
UNION 指令的目的是将两个 SQL 语句的结果合并起来。从这个角度来看, UNION 跟 JOIN有些许类似,因为这两个指令都可以由多个表格中撷取资料。 UNION 的一个限制是两个
SQL 语句所产生的栏位需要是同样的资料种类。另外,当我们用 UNION 这个指令时,我们只会看到不同的资料值 (类似 SELECT DISTINCT)。
UNION 的语法如下:
[SQL 语句...
分类:
数据库 时间:
2014-12-15 19:10:15
阅读次数:
147
现在我们介绍连接 (Join) 的概念。要了解连接,我们需要用到许多我们之前已介绍过的指令。我们先假设我们有以下的两个表格,
Store_Information 表格
Store_Name
Sales
Txn_Date
Los Angeles
1500
05-Jan-1999
San Diego
250
07-Jan-1999
Los ...
分类:
数据库 时间:
2014-12-15 17:19:14
阅读次数:
234
exists的用法select *from haha where exists (select *from bumen where bumen.code = haha.bumen and bumen.name = '销售部' )and age>35(运行方法为逐条查询)select name,sex...
分类:
数据库 时间:
2014-12-15 16:43:32
阅读次数:
249
select DISTINCT human.tid,log_pv_change.systafftid from human left join human_user on human.tid=human_user.hid left join human_house on human.tid = hu...
分类:
其他好文 时间:
2014-12-15 10:14:40
阅读次数:
176
代码:select t1.descid, IFNULL(t2.cnt,0) as countnew, t1.description from uosdesc t1 left outer join t2on t1.descid=t2.descid order by...
分类:
数据库 时间:
2014-12-14 13:15:07
阅读次数:
150
微软近期Open的职位:Are you looking for a big challenge? Do you know why Big Data is the next frontier for innovation, competition and productivity? Come join...
分类:
其他好文 时间:
2014-12-14 11:56:51
阅读次数:
248
table1表结构(用户名,密码)useridusernamepassword1user1pwd12user2pwd2table2表结构(用户积分,等级)useridscorelevel12033506第一:内联(inner join)如果想把用户信息,积分,等级都列出来.那么一般会这样写selec...
分类:
数据库 时间:
2014-12-14 10:34:10
阅读次数:
208