sql 取反
update anketo1 set fb = substring('10',fb+1,1) WHERE id =5
后来问了BM,BM说直接取反
update anketo1 set fb = ~ fb WHERE id =5
我告诉了BM用substring也可以.
BM说:"这家伙厉害,这也能想出,这属于邪门武功."
最后又想到用ABS取绝对值也可以
update anketo1 set fb = abs(fb-1)
我觉得不管是什么武功,能制胜就是好的武功.
以上三种方法都是不错的方法.
相关文档:
SQL 中的 substring 函数是用来抓出一个栏位资料中的其中一部分。这个函数的名称在不同的资料库中不完全一样:
MySQL: SUBSTR(), SUBSTRING()
Oracle: SUBSTR()
SQL Server: SUBSTRING()
最常用到的方式如下 (在这里我们用SUBSTR()为例):
SUBSTR(str,pos): 由<str>中,选出所有从第<pos>位置开始 ......
Sql Server 中一个非常强大的日期格式化函数
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVERT(varchar(100), GE ......
ORDER BY 排序
ASC 升序(默认)
DESC 降序
select * from s_emp order by dept_id , salary desc
部门号升序,工资降序
关键字distinct也会触发排序操作。
select * from employee order by 1; //按第一字段排序
NULL被认为无穷大。order by 可以跟别名。
select table_name ......
1. 说明:复制表(只复制结构,源表名:a,新表名:b)
SQL: select * into b from a where 1<>1;
2. 说明:拷贝表(拷贝数据,源表名:a,目标表名:b)
SQL: insert into b(a, b, c) select d, e, f from b;
&nb ......
General Overview
FeatureSQL Server 2008 (RC0)MySQL 5.1/6PostgreSQL 8.3/PostGIS 1.3/1.4
OS
Windows XP, Windows Vista, Windows 2003, Windows 2008
Windows XP, Windows Vista, (haven't tested on 2008), Linux, Unix, Mac
Windows 2000+ (including Vista and 2003, haven't tested on 2008), Linux, Unix, Ma ......