MYSQL中的单等于 [英] Single Equals in MYSQL
问题描述
我想知道为什么MYSQL在条件语句中使用单个等号而不是更典型的两个等号.是否有技术/历史原因?谢谢.
I was wondering why MYSQL uses a single equals sign in conditional statements instead of the more typical two equals signs. Is there a technical/historical reason for this? Thanks.
推荐答案
我想知道为什么MYSQL在条件语句中使用单个等号而不是更典型的两个等号.是否有技术/历史原因?谢谢.
Hi, I was wondering why MYSQL uses a single equals sign in conditional statements instead of the more typical two equals signs. Is there a technical/historical reason for this? Thanks.
SQL
中的比较比赋值更常见.
Comparison is much more common in SQL
than assignment.
这就是为什么SQL
使用更短的语法来完成更多常见事情的原因.
That's why SQL
uses more short syntax to do more common things.
在经典的SQL
中,可以通过上下文将比较与赋值区分开(赋值只能在UPDATE
语句的SET
子句中),这就是为什么两个运算符都可以使用一个运算符的原因.
In classical SQL
, comparison can be distinguished from assignment by context (assignment can be only in SET
clause of an UPDATE
statement), that's why one operator can be used for both operations.
在MySQL
对SQL
的扩展中,对会话变量的分配由:=
In MySQL
's extension to SQL
, assignment to a session variable is denoted by :=
这篇关于MYSQL中的单等于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!