[wellylug] Weird MySQL problem.

Jethro Carr jethro.carr at jedolinux.com
Sat May 14 21:47:52 NZST 2005


On Sat, 2005-05-14 at 18:46, jumbophut wrote:
> 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 $(())).


good point Tony. :-)


however, I only refer to the table names when I need to grab their data
from the database.

eg: SELECT * FROM `table-name` WHERE id='$id'

so it's not too likely to be a problem. however, I better keep your
points in mind for future.

cheers,

-- 
-- Jethro Carr

jethro.carr at jedolinux.com

http://jethrocarr.jedolinux.com
http://jethrocarr.jedolinux.com/index.php?page=cv/cv.php

http://www.jedolinux.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20050514/51d42954/attachment.pgp 


More information about the wellylug mailing list