由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Like 和 equal 啥区别?
相关主题
用SSIS EXPORT 到 EXCEL 2010 有2000个COLUMN,可能吗What is a relational table?
How to split a column into several rows?Help on Sql server huge table performance
一个关于T-SQL的问题Please Help! ORA-00918: column ambiguously defined
这个新功能我喜欢Rookie's question again
请教SQLsql server 面试题 (9)
how to extract textHelp! A cluster method in SQL
how to get the result in the middle of resultset?random error for CAST( MONEY AS VARCHAR)
[转载] what's wrong with this PL/SQLMDX Cube
相关话题的讨论汇总
话题: 2007话题: like话题: column话题: select话题: where
进入Database版参与讨论
1 (共1页)
S***k
发帖数: 370
1
sql 2005
一个column nvarchar(50), 里面的数据:
2007
2008
2007 and 2008
...
select *
from table
where column = '2007'
return 1100 rows
select *
from table
where column like '2007'
return 900 rows
column = '2007' 和 column like '2007' 有什么区别?
n********6
发帖数: 1511
2
Some examples.
TABLEA.COLUMNA
'20070101'
@DATA LIKE '2007%'
@DATA = SUBSTRING('20070101', 1, 4)
TABLEB.COLUMNB
'12132007'
LIKE '____2007' *4 underscores
LIKE '%2007'
More
TABLEC.COLUMNC
'03/16/2007'
...
B*****g
发帖数: 34098
3
can you post result for
select *
from table
where column = '2007'
except
select *
from table
where column like '2007'

【在 S***k 的大作中提到】
: sql 2005
: 一个column nvarchar(50), 里面的数据:
: 2007
: 2008
: 2007 and 2008
: ...
: select *
: from table
: where column = '2007'
: return 1100 rows

S***k
发帖数: 370
4
The column was designed to hold customized input from users and not
specific to hold date time string.

Select *
From table
Where col = ‘2007’
Except
Select *
From table
Where col like ‘2007’
The number of returned rows is the difference between two queries. And all
of these records have 2007 in that column.
B*****g
发帖数: 34098
5
???
can you just post some data from the sql with except?

【在 S***k 的大作中提到】
: The column was designed to hold customized input from users and not
: specific to hold date time string.
:
: Select *
: From table
: Where col = ‘2007’
: Except
: Select *
: From table
: Where col like ‘2007’

c**t
发帖数: 2744
6
The difference is likely to be in trailing space.
The = op ignores trailing space, but like does NOT.

【在 S***k 的大作中提到】
: sql 2005
: 一个column nvarchar(50), 里面的数据:
: 2007
: 2008
: 2007 and 2008
: ...
: select *
: from table
: where column = '2007'
: return 1100 rows

a*******t
发帖数: 891
7
select *
from table
where column = '2007'
and not in
(select *
from table
where column like '2007')
see what's the difference.

【在 S***k 的大作中提到】
: sql 2005
: 一个column nvarchar(50), 里面的数据:
: 2007
: 2008
: 2007 and 2008
: ...
: select *
: from table
: where column = '2007'
: return 1100 rows

B*****g
发帖数: 34098
8
how can = ignores trailing space?

【在 c**t 的大作中提到】
: The difference is likely to be in trailing space.
: The = op ignores trailing space, but like does NOT.

c**t
发帖数: 2744
9
select '<' + col + '>' ...
c**t
发帖数: 2744
10
http://support.microsoft.com/kb/316626
SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, <
Comparison Predicate>, General rules #3) on how to compare strings with
spaces. The ANSI standard requires padding for the character strings used in
comparisons so that their lengths match before comparing them. The padding
directly affects the semantics of WHERE and HAVING clause predicates and
other Transact-SQL string comparisons. For example, Transact-SQL considers
the strings 'abc' an

【在 B*****g 的大作中提到】
: how can = ignores trailing space?
相关主题
how to extract textWhat is a relational table?
how to get the result in the middle of resultset?Help on Sql server huge table performance
[转载] what's wrong with this PL/SQLPlease Help! ORA-00918: column ambiguously defined
进入Database版参与讨论
B*****g
发帖数: 34098
11
ding

in
padding
operations.

【在 c**t 的大作中提到】
: http://support.microsoft.com/kb/316626
: SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, <
: Comparison Predicate>, General rules #3) on how to compare strings with
: spaces. The ANSI standard requires padding for the character strings used in
: comparisons so that their lengths match before comparing them. The padding
: directly affects the semantics of WHERE and HAVING clause predicates and
: other Transact-SQL string comparisons. For example, Transact-SQL considers
: the strings 'abc' an

S***k
发帖数: 370
12
It is caused by the trailing space.
I used len(col) to check the length. It seems len() also ignore the trailing
space.
Thanks, guys.
j*****n
发帖数: 1781
13
nice call!

in
padding
operations.

【在 c**t 的大作中提到】
: http://support.microsoft.com/kb/316626
: SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, <
: Comparison Predicate>, General rules #3) on how to compare strings with
: spaces. The ANSI standard requires padding for the character strings used in
: comparisons so that their lengths match before comparing them. The padding
: directly affects the semantics of WHERE and HAVING clause predicates and
: other Transact-SQL string comparisons. For example, Transact-SQL considers
: the strings 'abc' an

c**t
发帖数: 2744
14
居然没有包子,呵呵

【在 j*****n 的大作中提到】
: nice call!
:
: in
: padding
: operations.

S***k
发帖数: 370
15
俺。。。
穷人那。
问问题有没有包子哈?
1 (共1页)
进入Database版参与讨论
相关主题
MDX Cube请教SQL
这个 Oracle SQL 语句该这么写啊?how to extract text
SQL find distinct values in large tablehow to get the result in the middle of resultset?
T-SQL Row Concatenate with a Twist??[转载] what's wrong with this PL/SQL
用SSIS EXPORT 到 EXCEL 2010 有2000个COLUMN,可能吗What is a relational table?
How to split a column into several rows?Help on Sql server huge table performance
一个关于T-SQL的问题Please Help! ORA-00918: column ambiguously defined
这个新功能我喜欢Rookie's question again
相关话题的讨论汇总
话题: 2007话题: like话题: column话题: select话题: where