If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Needs your help, both of following sql syntax produce same result in MySql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-09, 03:12
slamet_mjk slamet_mjk is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
Question Needs your help, both of following sql syntax produce same result in MySql

Hi All,

Needs your help, both of following sql syntax produce same result in MySql:

(1)FilterValue without space

Select * from SomeTable
where Column1 = 'FilterValue';

(2)FilterValue with space

Select * from SomeTable
where Column1 = 'FilterValue ';


How to configure, so both of sql syntax produce different result ?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-22-09, 03:39
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
Quote:
Originally Posted by slamet_mjk View Post
...How to configure, so both of sql syntax produce different result ?.
they give different results because you are asking a different question and the two statements are mutually exclusive.

Code:
where Column1 = 'FilterValue';
is not the same as
Code:
where Column1 = 'FilterValue ';
the options are
Code:
where Column1 = 'FilterValue' or Column1 = 'FilterValue ';
or use a wildcard match
Code:
where Column1 like 'FilterValue%';
or just search column1 that starts with FilterValue
Code:
where Column1 like 'FilterValue';
or you may be able to use the in predicate
Code:
where Column1 in (blah, blahdi, blahdiblah);
so I'd suggest you look at the MySQL manual for wildcard searches or matches
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 12-22-09, 03:56
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by healdem View Post
they give different results because you are asking a different question and the two statements are mutually exclusive.
The question was how to get different results. The OP is getting the same result for both queries.


Quote:
Originally Posted by slamet_mjk
How to configure, so both of sql syntax produce different result ?
You neither stated the data type you are using nor the MySQL version you are using.

But I assume you are affected by the following situation:
Quote:
Originally Posted by MySQL Manual
As of MySQL 5.0.3, trailing spaces are retained when values are stored and retrieved, in conformance with standard SQL. Before MySQL 5.0.3, trailing spaces are removed from values when they are stored into a VARCHAR column; this means that the spaces also are absent from retrieved values
Taken from http://dev.mysql.com/doc/refman/5.0/en/char.html
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On