1.使用distinct查询所有不重复的记录 2.创建数据表相同结构的临时表,将第一步的数据复制进去 create temporary table if not exists student_temp as (select distinct(name), sex from student); 3.truncate table student; 4.insert into student(id,name,sex) select null,name,sex from student_temp;…
http://kb.cnblogs.com/a/2357592/很多情况下,我们要提前用到当前某个表的auto_increment自增列id,可以通过执行sql语句来查询到这个id值. show table status where name=’表名’ 或者 show table status like ‘表名’ 然后从查询到的结果集中获得auto_increment的值 代码实例:<?php mysql_connect("localhost","root",…
原文:SQL Server 2008空间数据应用系列五:数据表中使用空间数据类型 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2008 R2调测. 2.具备 Transact-SQL 编程经验和使用 SQL Server Management Studio 的经验. 3.熟悉或了解Microsoft SQL Server 2008中的空间数据类型. 4.具备相应(比如OGC)的GIS专业理论知识. 5.其他相关知识. 通过前面几篇文章介绍了…
编写sql语句中,经常需要编写获取一张数据表中不存在与另一张表的数据,相关编写方法如下: 方法1: 使用not in ,效率低下,在数据较小的情况下可以采用如下编写 SELECT * FROM a AND a.Id NOT IN( SELECT Id FROM B WHERE B.IsDeleted GROUP BY B.Id ); 方法2:使用left join 较第一种方法快 SELECT * FROM a LEFT JOIN b ON a.Id=b.Id AND b.Id IS NULL…