Forum Moderators: open

Message Too Old, No Replies

hyphen in database name causing problem with 2xDB join

         

jamie

6:56 pm on Aug 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

i have two tables, table-one and table_two. when i try to join them,

SELECT table-one.clients.ID
FROM table-one.clients
LEFT JOIN table_two.clients
ON table_two.clients.ID = table-one.clients.ID
AND table_two.clients.ID IS NOT NULL

mysql always barfs on the hyphen. if i were to change the hyphen to an underscore it would work. unfortunately the database in question is very large and in production, so i would rather not change the name.

is there a way to escape the hyphen? i have tried \- but that doesn't work.

thanks!

brotherhood of LAN

7:00 pm on Aug 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



`tablename`.`columnname`

using backticks should remedy it

coopster

3:31 pm on Aug 28, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Just adding a resource: identifiers and qualifiers [dev.mysql.com]

jamie

2:23 pm on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



many thanks both - works a charm!