文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>MySQL Logical Operators

MySQL Logical Operators

时间:2008-09-25  来源:bj2008_0201


Logical Operators

One of the great features within MySQL is its full support for logical operations. I will name off, and show examples of them below

mysql> CREATE TABLE users (
-> id INT NOT NULL AUTO_INCREMENT,
-> name VARCHAR (50),
-> email VARCHAR (50),
-> PRIMARY KEY (id));

NOT (or) !

mysql> SELECT * FROM users WHERE
-> (name != "Blair Ireland");

or

mysql> SELECT * FROM users WHERE
-> (name NOT = "Blair Ireland");

This query would return all records without Blair Ireland present as the name.

AND (or) &&

mysql> SELECT * FROM users WHERE
mysql> (name = "Blair Ireland") AND mysql> (email = "[email protected]");

or

mysql> SELECT * FROM users WHERE
-> (name = "Blair Ireland") &&
-> (email = "[email protected]");

This query would return all records with Blair Ireland present as the name, and [email protected] as the email.

OR ( or ) ||

mysql> SELECT * FROM test WHERE
-> (name = "Blair Ireland") OR
-> (email = "[email protected]");

or

mysql> SELECT * FROM test WHERE
-> (name = "Blair Ireland") ||
-> (email = "[email protected]");

This query would return all records with Blair Ireland present as the name, or records with [email protected] as the email.

相关阅读 更多 +
排行榜 更多 +
奥丘树海之下小米服手游下载

奥丘树海之下小米服手游下载

角色扮演 下载
网络天才国际服手游下载

网络天才国际服手游下载

休闲益智 下载
御剑红尘手游官方版下载

御剑红尘手游官方版下载

角色扮演 下载