[wellylug] Weird MySQL problem.

jumbophut jumbophut at gmail.com
Sat May 14 18:46:09 NZST 2005


On 5/14/05, Jethro Carr wrote:
> For some reason, mysql didn't surrond the table names with back quotes
> (ie: `table-name`) when it got exported. When I add a table containing a
> dash with backquotes it works!
> 

Well okay, it works now, but perhaps this was nature's way of warning
you about the perils of using a '-' in a name in a language where '-'
is also the mathematical subtraction operator. :-)

You can imagine accidentally typing something like:
select amount-owing - amount-paid from billing

where you really meant:
select `amount-owing` - `amount-paid` from billing

It would just return an error most of the time, but if the billing
table happened to also have 'amount', 'owing' and 'paid' fields, it
would actually return the wrong answer.

It's possible to use the dash, but presumably an underscore, if
allowed, would be safer?

(This doesn't apply to filenames in bash et al., since '-' is only the
subtraction operator if you embed it in $(())).

 -- 
Tony (echo 'spend!,pocket awide' | sed 'y/acdeikospntw!, /l at omcgtjuba.phi/')




More information about the wellylug mailing list