文章分类 -  数据库

something
select then insert
摘要:一:如果要插入目标表不存在: select * into 目标表 from 表 where ... 二:如果要插入目标表已经存在: insert into 目的表 select * from 表 where 条件 三:如果是跨数据库操作的话: 怎么把A数据库的atable表所查询的东西,全部插入到B 阅读全文

posted @ 2017-03-26 21:59 blbl9527 阅读(88) 评论(0) 推荐(0)

where & having
摘要:where 和 having 都是那啥。。 区别: 1.where先执行,having后执行 2.where后面的列名称必须是数据库表中的列的名称,但是having后面的列的名称是一个查询语句select出的列的名称或者别名或者聚合函数结果的别名。 select usrname,usrid,pass 阅读全文

posted @ 2017-03-26 21:55 blbl9527 阅读(70) 评论(0) 推荐(0)

sql语句的执行顺序
摘要:恢复内容开始 下面是一条典型的sql语句: select distinct <col1,col2,...> from <left_tab> <join_type> join <right_tab> on<join_condition> where<condition> group by<col1,c 阅读全文

posted @ 2017-03-06 15:48 blbl9527 阅读(115) 评论(0) 推荐(0)

子查询
摘要:IN select * from foo where id in (select max(id) from foo ); select * from foo where id NOT in (select max(id) from foo ); EXISTS select * from foo wh 阅读全文

posted @ 2017-03-06 14:47 blbl9527 阅读(71) 评论(0) 推荐(0)

导航


github sina微博 FB