English 中文(简体)
是否有理由不使用“<=>(无安全平等经营者)”。
原标题:Is there a reason not to use <=> (null safe equals operator) in mysql instead of =?

MySQL提供一台冰操作员<=>,该仪器可包含一种可包含如下内容的不成文:null <=> 无null <=> 5 等等,给许多方案拟定语言的反馈结果。 正常的平等经营人总是只取得回报,而这种回报却赶走了许多新的MySQL用户,如我本人。

MySQL是否具备以下功能:<=>? 谁真正需要一个没有用语言类型建造的经营者?

问题回答

谁真正需要一个没有用语言类型建造的经营者?

You asked for some real-world examples. Here s a spurious one. Let s say that you have a residential youth programme or similar, and one of the requirements is that the kids only share a room with someone of the same sex. You have a nullable M/F field in your database - nullable because your data feed is incomplete (you re still chasing down some of the data). Your room-matching code should definitely not match students where t1.Gender<=>t2.Gender, because it could end up matching two kids of unknown gender, who might be of opposite genders. Instead, you match where they re equal and not both null.

That s just one example. I admit that the behaviour of NULL and the = operator have caused a lot of confusion over the years, but ultimately the fault probably lies with the plethora of online MySQL tutorials that make no mention of how NULL interacts with operators, nor of the existence of the <=> operator.

我的SQL语和节目编排语言的“无效”之间的巨大差异是,在我的SQL中,“无”一词是指un known。 在制定方案时,这意味着un specified数值。

In mySQL, null does not equal null (unknown does not equal unknown). While in programming languages, null does equal null (undefined equals undefined).

Who really needs an operator that is effectively undefined with built in language types?

您也需要在您的数据库内建立关系。 尤其是,如果你利用外国的关键制约因素的话。

for example if you have a table for tasks (in your company). then you assign these tasks to employees. so you have a relation from your tasks-table to your employees-table.
and there will always be some unassigned tasks. in this case the field in your tasks-table you use for the relation to the employees table will contain NULL. this will make sure, that this task is unassigned. which means: there is no possibility that there is a relation to the employees table.

如果NULL = NULtrue,那么,举例来说,雇员表中的外国钥匙也总是有可能成为NUL。 因此,这项任务将分配给一名或多名雇员。 你们永远无法知道某项任务被指派给某些雇员。

是的。

This must be because relational databases use the theory of three-valued logic (TRUE, NULL, FALSE).

而三维 l必须努力,因为它必须是内部的。

依据的是数学规则。

Comparisons with NULL and the three-valued logic

Is there a reason MySql has both and not JUST the functionality in <=> ? The operators are completely different from each other.

<代码><=> 进行平等比较,如<代码>=的操作者,但<代码>1。 两种操作方式均为NUL0。 缩略语

Who really needs an operator that is effectively undefined with built in language types?

This depends on case, just because you haven t encountered such cases, does not mean nobody needs it.

当<代码><=> 无效的等同操作者与NOT的操作者结合时,该编码适合实际使用世界的情况。 返回记录如不停:

<编码> WHERE NOT d或mant_status <=> Y

相当于

。 Y (仅在某些数据库有效)

WHERE d或mant_status <> Y OR d或mant_status IS NULL





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签