MySQL不支持INTERSECT和MINUS,及其替代方法
Doing INTERSECT and MINUS in MySQL
By Carsten | October 3, 2005
Doing an INTERSECT
An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So
SELECT member_id, name from a
INTERSECT
SELECT member_id, name from b
can simply be rewritten to
SELECT a.member_id, a.name
from a INNER JOIN b
USING (member_id, name)
Performing a MINUS
To transform the statement
SELECT member_id, name from a
MINUS
SELECT member_id, name from b
into something that MySQL can process, we can utilize subqueries (available from MySQL 4.1 onward). The easy-to-understand transformation is:
SELECT DISTINCT member_id, name
from a
WHERE (member_id, name) NOT IN
(SELECT member_id, name from table2);
Of course, to any long-time MySQL user, this is immediately obvious as the classical use-left-join-to-find-what-isn’t-in-the-other-table:
SELECT DISTINCT a.member_id, a.name
from a LEFT JOIN b USING (member_id, name)
WHERE b.member_id IS NULL
相关文档:
1、新建动态web项目。
2、添加jar包
将mysql jdbc驱动添加到tomcat安装目录下的lib目录。
3、在META-INF下添加content.xml文件。内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<!-- Default set of monitored resources - ......
mysql procedure 没有return参数 可以out一个变量给客户端 但是out参数又不支持游标类型,如何能out出一个结果集呢?
方法很简单 就是在procedure里执行一个select (select .... from ...)
eg.
CREATE PROCEDURE `CREATE_ACCOUNT`(
ACCOUNT CHAR(32),
PASSWORD CHAR(32), ......
首先建一个工程,准备好一个log4j的jar包和连接MySqL的驱动包。配置如下:
修改log4j.properties文件:
######## #此句为定义名为stdout的输出端是哪种类型,可以是
#org.apache.log4j.ConsoleAppender(控制台),
#org.apache.log4j.FileAppender(文件),
#org.apache.log4j.DailyRollingFileAppender(每天产生一 ......
首先建一个工程,准备好log4j的jar包和MysqL的驱动包。
配置log4j.properties文件:
#此句为定义名为stdout的输出端是哪种类型,可以是
#org.apache.log4j.ConsoleAppender(控制台),
#org.apache.log4j.FileAppender(文件),
#org.apache.log4j.DailyRollingFileAppender(每天产生一个日志文 ......
卸载MySQL数据库:
先停掉WINDOWS里的MySQL服务;
用360安全卫士强行删除MySQL数据库
接着在注册表里清除MySQL服务:
1、HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL 目录删除
2、HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL 目录删除
3、HKEY_ ......