English 中文(简体)
比较一下我的SQL中超过或低于的扼杀是否安全?
原标题:Is it safe to compare strings with greater than and less than in MySQL?

5. MySQL(5.1.41-3ubuntu12.10-log)似乎在使用和开发(大于)和(以下)进行细化比较方面取得了可预见的成果:

select "a" > "a", "a" > "b", "b" > "a", "ab" > "aa", "ab" > "aabbbb";
+-----------+-----------+-----------+-------------+-----------------+
| "a" > "a" | "a" > "b" | "b" > "a" | "ab" > "aa" | "ab" > "aabbbb" |
+-----------+-----------+-----------+-------------+-----------------+
|         0 |         0 |         1 |           1 |               1 | 
+-----------+-----------+-----------+-------------+-----------------+

并且似乎还利用了关键因素:

explain select productcode from products where productcode <  no ; 
+----+-------------+----------+-------+-----------------+------+---------+------+------+--------------------------+
| id | select_type | table    | type  | possible_keys   | key  | key_len | ref  | rows | Extra                    |
+----+-------------+----------+-------+-----------------+------+---------+------+------+--------------------------+
|  1 | SIMPLE      | products | range | productcode,ppp | ppp  | 34      | NULL |  432 | Using where; Using index |
+----+-------------+----------+-------+-----------------+------+---------+------+------+--------------------------+

这似乎没有记录——它是否是一个可靠的跨平台特征?

最佳回答

我认为有一些 go,你可以在这里查看一些细节的文件:

http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html

If your fields have null values too, you should also take a look at null-safe comparision operator: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_equal-to

例如:

mysql> select "a" > "a ", "A" > "a" , "aB"  > "ab" , "a" >= NULL , "a" <=> NULL ;
+------------+-----------+--------------+-------------+--------------+
| "a" > "a " | "A" > "a" | "aB"  > "ab" | "a" >= NULL | "a" <=> NULL |
+------------+-----------+--------------+-------------+--------------+
|          0 |         0 |            0 |        NULL |            0 |
+------------+-----------+--------------+-------------+--------------+
问题回答

这些比较很常见。 我确信,将体积与面值相比较,或像支持交叉面形的其他编码。 我拿不出任何资源支持它。 这很可能是比较内部的扼杀(以分类和分类)。 我预计,这是一个主要特点。

<>光:<> 之所以可以预测,是因为将所涉数值分类为collation(s)

About comparison in general

MySQL类转换 docs,“比较业务的转变”:

如果比较行动中的两个论点都很明确,它们是,而后称“strong”。

www.un.org/Depts/DGACM/index_spanish.htm 与之相比,是指所涉数值/栏的collation(s)的分类算法。

About multiple collations involved

如果对与不同串通的两条歌剧(栏目,字面......)进行对比,那么会如何? 见MySQL colation coersion





相关问题
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 ...

热门标签