上一篇:PHP4之真OO >>
mysql中2个非常有用的查询
第一个:
insert ... select syntax
用处:数据转换(特别是数据量大的时候),我测试过。转换100万数据也只是用秒计划就ok了。
insert [low_priority] [ignore] [into] tbl_name [(column list)]
select ...
with insert ... select, you can quickly insert many rows into a table from one or many tables.
for example:
insert into tbltemp2 (fldid)
select tbltemp1.fldorder_id from tbltemp1
where tbltemp1.fldorder_id > 100;
the following conditions hold for an insert ... select statement:
prior to mysql 4.0.1, insert ... select implicitly operates in ignore mode. as of mysql 4.0.1, specify ignore explicitly to ignore records that would cause duplicate-key violations.
do not use delayed with insert ... select.
prior to mysql 4.0.14, the target table of the insert statement cannot appear in the from clause of the select part of the query. this limitation is lifted in 4.0.14.
auto_increment columns work as usual.
to ensure that the binary log can be used to re-create the original tables, mysql will not allow concurrent inserts during insert ... select.
you can use replace instead of insert to overwrite old rows. replace is the counterpart to insert ignore in the treatment of new rows that contain unique key values that duplicate old rows: the new rows are used to replace the old rows rather than being discarded.
2.in的用法。这个好处很多。特别是删除数据的时候可以不用whil循环就行了
比如语句:
$sql = sprintf("delete from ".productoption_table." where (productoptionid in (%s))",join(",", $_post[fieldsid]));
$db->query($sql);
就直接把一个产品列表中数据全删除了
还有查询的时候同样很有用。就不写了。随便乱写的
()
下一篇:N个To动网论坛转换程序+数据库合并工具 >>
相关文章:
- · ASP漏洞全接触-高级篇
- · 轻松玩转弹出窗口
- · ASP漏洞全接触-入门篇
- · IIS服务器组建攻略
- · 其实做小偷是很容易的
- · XMLHTTP下载远程数据输出到浏览器
- · Jave基础学习:jdbc小技巧
- · 一棵php的类树(支持无限分类)
- · 用asp.net 实现九连环小游戏
- · MySQL数据导入导出方法与工具介绍(1)
- · 轻松弹出无边框网页的Javscrpt代码
- · ASP初学者参考
- · Java新手学习:IIS6和Tomcat5的整合
- · asp常用函数
- · W3 Jmail中文使用说明
- · 无组件上传图片到数据库中,最完整解决方案
- · 二级域名原理以及程序,申请即可开通
- · Java学习过程的一些重点
- · Oracle9i中如何建立不同字符集的数据库
- · 修复SQL Server 2000数据库之实战经验
- · 使用ASP生成HTML文件
- · 编写安全的ASP代码
- · 十天学会ASP.net(2)
- · 十天学会ASP.net(1)
- · 十天学会php(2)
- · 十天学会php(1)
- · 三天学好ADO
- · 在数据库中存取文件
- · 解决大字段在Form中Post出错的方法
- · 利用ASP+JMAIL进行邮件群发的新思路
- · 关于处理GET方式提交的含有特殊字符的参数
- · 关于Adodb.Stream 的使用说明
- · 多文件多文本框上传程序
- · 让妙客家标准版使用 SQL Server 数据库后台
- · 关于用SQL SERVER2000建立分布式网站系统的认识
- · 使用SQLSERVER的扩展存储过程实现远程备份与恢复
- · MySQL数据库类的定义
- · SQL语句导入导出大全
