public inbox for [email protected]
help / color / mirror / Atom feedFrom: Scott Ribe <[email protected]>
To: M Sarwar <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: The same result for with SPACE and without SPACE
Date: Wed, 14 Jun 2023 16:47:21 -0600
Message-ID: <[email protected]> (raw)
In-Reply-To: <DM4PR19MB59784B518F25D2C2292CA3FBD35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
References: <DM4PR19MB5978EB964FA1C7B55FFCB02DD35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
<DM4PR19MB59782360E0C452810D70CBE8D35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
<[email protected]>
<DM4PR19MB59784B518F25D2C2292CA3FBD35AA@DM4PR19MB5978.namprd19.prod.outlook.com>
> On Jun 14, 2023, at 4:31 PM, M Sarwar <[email protected]> wrote:
>
> I expect this to behave the same way whether it comes from CHAR or VARCHAR.
Why would you expect that??? CHAR explicitly means that:
1) shorter strings will be space-padded to the given length
2) if a string is presented with spaces making it longer, it will be truncated
Putting it all together, it implies:
3) trailing spaces are semantically meaningless
Anyway, the closest I could to finding a reference on comparison behavior for this case states: "The ANSI standard requires padding for the character strings used in comparisons so that their lengths match before comparing them."
And there you go, you used CHAR(10), so all values in the table are space-padded to length 10, so for comparison *any* value will be space-padded to 10.
view thread (22+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: The same result for with SPACE and without SPACE
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox