sql 备忘
**************************************
**** sql 查询备忘 ****
**************************************
一:外连接:
1、左外连接(把join左边表里的所有数据都查出来。然后把join 右边表中的符合条件的数据加在左边表的后面。。。。)
SELECT * from t_empl_info as a LEFT OUTER JOIN t_dept as b
ON a.dept_no=b.dept_id
--通常情况下是:左边表是多方表。右边表是一方表
--三张表的左外连接
SELECT *
from A left join B
on A.a=B.a
left join C on B.b = C.b;
相关文档:
1.使用Management Studio Express,用“Windows身份验证”登录,选中SQL服务器名,右击鼠标选择属性,在服务器属性选项页面,选择“安全性”,将服务器身份验证由 “Windows身份验证”改为“SQL Server和Windows身份验证”,单击确定。
2.使用SQL Server 2005外围应用配置器,选 ......
--1. 创建表,添加测试数据
CREATE TABLE tb(id int, [value] varchar(10))
INSERT tb SELECT 1, 'aa'
UNION ALL SELECT 1, 'bb'
UNION ALL SELECT 2, 'aaa'
UNION ALL SELECT 2, 'bbb'
UNION ALL SELECT 2, 'ccc'
--SELECT * from tb
/**//*
id value
----------- ----------
1 aa
1 bb
2 aaa
......
1. Q. What is a join?
A. Join is a process of retrieve pieces of data from different sets (tables) and returns them to the user or program as one joined collection of data.
2. Q. Can a table have more than one foreign key defined?
A. A table can have any number of foreig ......
很多时候我们可能都需要这么一个简繁互相转换的SQL函数,今天在网上找到的,收集下来。
以后有了它就省事多啦。不用再写程序取出来转换后再更新数据库了。
SQL简体繁体转换函数代码:
--生成码表
if exists (select * from dbo.sysobjects where id = object_id(N'[codetable]') and OBJECTPROPERTY(id, N'IsUserTable' ......
--
SQL Server Split函数
--
Author:zc_0101
--
说明:
--
支持分割符多字节
--
使用方法
--
Select * from DBO.F_SQLSERVER_SPLIT('1203401230105045','0')
--
select * from DBO.F_SQLSERVER_SPLIT('abc1234a12348991234',' ......