![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
What does the 'like' expression look like for a zero length string? select * from x where something Like %% |
#3
| |||
| |||
|
|
In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE atall? There's no "pattern" to match, only an exact value. So the answer to your question is, SELECT * FROM x WHERE something = ''; |
#4
| |||
| |||
|
|
On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article<b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin<bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE at all? There's no "pattern" to match, only an exact value. So the answer to your question is, SELECT * FROM x WHERE something = ''; You need to be careful with inserting "emtpy" strings. If you used the \where something=''/ would return no rows as it equates empty string '' as NULL. You would get the correct results if you used "where something is NULL;" My "MySQL" system is currently unavailable to test how it behaves. |
#5
| |||
| |||
|
|
On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE at all? There's no "pattern" to match, only an exact value. So the answer to your question is, SELECT * FROM x WHERE something = ''; You need to be careful with inserting "emtpy" strings. If you used the \where something=''/ would return no rows as it equates empty string '' as NULL. You would get the correct results if you used "where something is NULL;" My "MySQL" system is currently unavailable to test how it behaves. |
#6
| |||
| |||
|
|
onedbguru wrote: On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKEat all? There's no "pattern" to match, only an exact value. So the answer to your question is, SELECT * FROM x WHERE something = ''; You need to be careful with inserting "emtpy" strings. *If you used the \where something=''/ *would return no rows as it equates empty string '' as NULL. *You would get the correct results if you used "where something is NULL;" *My "MySQL" system is currently unavailable to test how it behaves. IME NULL is not the same as a zero length string at all. Upate..set (field1=NULL) seems to give a different value from set(field1='') I have had some weird an interesting bugs because of this. |
#7
| |||
| |||
|
|
On Mar 1, 8:05*pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid wrote: onedbguru wrote: On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE at all? There's no "pattern" to match, only an exact value. So the answer toyour question is, SELECT * FROM x WHERE something = ''; You need to be careful with inserting "emtpy" strings. *If you used the \where something=''/ *would return no rows as it equates empty string '' as NULL. *You would get the correct results if you used "where something is NULL;" *My "MySQL" system is currently unavailable to test how it behaves. IME NULL is not the same as a zero length string at all. Upate..set (field1=NULL) seems to give a different value from set(field1='') I have had some weird an interesting bugs because of this. All that I was saying was that you need to be careful... Not all database engines treat empty string the same as null. Not saying that it is correct behavior, but there are db engines out there that an empty string is equal to NULL value. *There are tons of articles written on the treatment of ES vs NULL and you can look them up. In MySQL, it would be interesting to dump the data block to see what is actually stored on disk to differentiate ES vs NULL. *In some {unnamed} *database engines, no value is stored as HEX 00 (aka NULL). |

#8
| |||
| |||
|
|
On Mar 1, 8:05=A0pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid wrote: onedbguru wrote: On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroup= s.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE= at all? There's no "pattern" to match, only an exact value. So the answer to y= our question is, SELECT * FROM x WHERE something =3D ''; You need to be careful with inserting "emtpy" strings. =A0If you used the \where something=3D''/ =A0would return no rows as it equates empty string '' as NULL. =A0You would get the correct results if you used "where something is NULL;" =A0My "MySQL" system is currently unavailabl= e to test how it behaves. IME NULL is not the same as a zero length string at all. Upate..set (field1=3DNULL) seems to give a different value from set(field= 1=3D'') I have had some weird an interesting bugs because of this. All that I was saying was that you need to be careful... Not all database engines treat empty string the same as null. |
#9
| ||||
| ||||
|
|
On Mar 2, 4:48=A0pm, onedbguru <onedbg... (AT) yahoo (DOT) com> wrote: On Mar 1, 8:05=A0pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid wrote: onedbguru wrote: On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article <b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegro= ups.com>, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LI= KE at all? There's no "pattern" to match, only an exact value. So the answer to= your question is, SELECT * FROM x WHERE something =3D ''; You need to be careful with inserting "emtpy" strings. =A0If you used the \where something=3D''/ =A0would return no rows as it equates empt= y string '' as NULL. =A0You would get the correct results if you used "where something is NULL;" =A0My "MySQL" system is currently unavaila= ble to test how it behaves. IME NULL is not the same as a zero length string at all. Upate..set (field1=3DNULL) seems to give a different value from set(fie= ld1=3D'') I have had some weird an interesting bugs because of this. All that I was saying was that you need to be careful... Not all database engines treat empty string the same as null. Not saying that it is correct behavior, but there are db engines out there that an empty string is equal to NULL value. There are tons of articles written on the treatment of ES vs NULL and you can look them up. In MySQL, it would be interesting to dump the data block to see what is actually stored on disk to differentiate ES vs NULL. In some {unnamed} database engines, no value is stored as HEX 00 (aka NULL). Right.. That's why I wanted it to be LIKE '%%' and not = '' ![]() What, so you could match a NULL? Won't work. No LIKE predicate will ever match |
|
bar | fubar | +------+-------+ 1 | | 3 | abc | +------+-------+ |
|
bar | fubar | +------+-------+ 1 | | +------+-------+ |
|
bar | fubar | +------+-------+ 2 | NULL | +------+-------+ |
#10
| |||
| |||
|
|
On Mar 1, 8:05 pm, The Natural Philosopher<t... (AT) invalid (DOT) invalid wrote: onedbguru wrote: On Mar 1, 4:17 pm, spamb... (AT) milmac (DOT) com (Doug Miller) wrote: In article<b8a5b877-d51b-4742-bb6e-cd3376dda... (AT) 8g2000prb (DOT) googlegroups.com>, SpreadTooThin<bjobrie... (AT) gmail (DOT) com> wrote: What does the 'like' expression look like for a zero length string? select * from x where something Like %% Think about it a little bit... If you're trying to match a zero-length string, why would you use LIKE at all? There's no "pattern" to match, only an exact value. So the answer to your question is, SELECT * FROM x WHERE something = ''; You need to be careful with inserting "emtpy" strings. If you used the \where something=''/ would return no rows as it equates empty string '' as NULL. You would get the correct results if you used "where something is NULL;" My "MySQL" system is currently unavailable to test how it behaves. IME NULL is not the same as a zero length string at all. Upate..set (field1=NULL) seems to give a different value from set(field1='') I have had some weird an interesting bugs because of this. All that I was saying was that you need to be careful... Not all database engines treat empty string the same as null. Not saying that it is correct behavior, but there are db engines out there that an empty string is equal to NULL value. There are tons of articles written on the treatment of ES vs NULL and you can look them up. |
|
In MySQL, it would be interesting to dump the data block to see what is actually stored on disk to differentiate ES vs NULL. In some {unnamed} database engines, no value is stored as HEX 00 (aka NULL). |
![]() |
| Thread Tools | |
| Display Modes | |
| |