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
相关文档:
源地址: http://www.pcppc.cn/shujuku/mysql/shujuku_163919.html
您正在看的MySQL教程是:MySQL数据库学习笔记。
MySQL数据库学习笔记
(实验环境:Redhat9.0,MySQL3.23.54)
纲要:
一,连接MySQL
二,MySQL管理与授权
三,数据库简单操作
四, ......
S- serv提权方式人人都会用了,搞得现在的主机都配置得非常安全,看来攻击手法的层出不穷也是造成中国网络安全进步的一大原因之一,还有其他的 pcanywhere获取密码,替换服务,等等。但是现在也没这么好搞了,随着安全意识的提高,之前的方式估计不怎么管用,现在我给大家介绍一下一种新的提权方式,看过古典LM做的那动画的 ......
启动mysql的服务经常发现1067这个错误。查看事件日志以后发现下面的错误信息
Unknown/unsupported table type: INNODB
如何解决:在mysql数据存放目录下找到 ibdata 以及ib_logfile0、ib_logfile1删掉再启动就好了 ......
转自http://www.linuxbyte.org/yi-ge-mysql-server-shang-de-xiao-ji-qiao.html
在my.cnf 的 mysql 端 添加如下设置
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
prompt="(\u:mysql1@linuxbyte.org \R:\m)[\d]: "
会产生如下效果:
root@ubuntu:/home/hew# mysql -u hew -p
Enter pass ......
MySQL中的流程函数
函数
功能
IF(value,t ,f)
如果value为真,返回t,否则返回f
IFNULL(value1,value2)
如果value1不为空返回value1,否则返回value2
CASE WHEN [value1] THEN [result1] … ELSE [default] END
如果value1为真 返回result2 否则返回default
CASE [expr] WHEN [value1] THEN [result1] &helli ......