随笔分类 -  sql

多表关联 update
摘要:UPDATE t_invests INNER JOIN t_user_coupons ON t_invests.user_coupon_id = t_user_coupons.id SET t_invests.virtual_product_id = t_user_coupons.virtual_product_id WHERE t_user_coupons.virtual_produc... 阅读全文

posted @ 2016-10-19 11:27 weiguoyuan 阅读(191) 评论(0) 推荐(0)

mysql 获得当前月1号的日期 和 0点日期方法
摘要:select timestamp(date_add(curdate(), interval - day(curdate()) + 1 day))当月0点时间:2015-12-01 00:00:00select timestamp(date_add(NOW(), interval - day(NOW(... 阅读全文

posted @ 2015-12-25 10:48 weiguoyuan 阅读(7112) 评论(0) 推荐(0)

SQL 基本关键字 函数 关联 连接
摘要:http://www.w3cschool.cn/sql_having.html w3c中有些SQL的讲解1 order by 排序SELECT Company, OrderNumber FROM Orders ORDER BY Company;2 distinct 去重SELECT DISTINCT... 阅读全文

posted @ 2015-01-27 17:01 weiguoyuan 阅读(594) 评论(0) 推荐(0)

SQL.Cookbook 读书笔记5 元数据查询
摘要:第五章 元数据查询 查询数据库本身信息 表结构 索引等5.1 查询test库下的所有表信息MYSQLSELECT * from information_schema.`TABLES` WHERE TABLE_SCHEMA = 'test';ORACLEselect table_name from a... 阅读全文

posted @ 2015-01-27 10:30 weiguoyuan 阅读(183) 评论(0) 推荐(0)

SQL.Cookbook 读书笔记4 插入更新和删除
摘要:第四章 插入更新和删除4.1 插入数据insert into dept (deptno,dname,loc) values (50,'PROGRA','NEW YOURK');4.2 从一个表向另一个表中复制insert into dept_east(deptno,dname,loc)select ... 阅读全文

posted @ 2015-01-26 16:26 weiguoyuan 阅读(206) 评论(0) 推荐(0)

SQL.Cookbook 读书笔记3 操作多个表
摘要:第三章 操作多个表表连接的内连接和外连接A表 B表id name id name 1 a 1 b 2 b 3 ... 阅读全文

posted @ 2015-01-23 11:39 weiguoyuan 阅读(216) 评论(0) 推荐(0)

SQL.Cookbook 读书笔记2 查询结果排序
摘要:第二章 查询结果排序2.1 按查询字段排序select ename,job,sal from emp where deptno = 10 order by sal asc;select ename,job,sal from emp order by deptno, 3 desc;-- 3表示sal... 阅读全文

posted @ 2015-01-22 15:28 weiguoyuan 阅读(229) 评论(0) 推荐(0)

SQL.Cookbook 读书笔记1 查询
摘要:本文内容摘自SQL.Cookbook一书第一章 select1.1 按条件查询select * from emp where deptno = 10 or comm is not null or sal = 4000 then 'OVERPARD' else 'OK' end ... 阅读全文

posted @ 2015-01-22 13:05 weiguoyuan 阅读(221) 评论(0) 推荐(0)

sql 语句生成命令 和SQL
摘要:用sql语句查询结果拼接字符串命令SELECT CONCAT(A.ofm_path_id,'-',A.distribute_address_id,'-',A.distribute_rule_id),A.in_file_abs_name, b.service_instance_name,b.insta... 阅读全文

posted @ 2013-12-02 11:32 weiguoyuan

导航