If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > # in query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-04, 15:10
greggyd greggyd is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
# in query

Hi,

I have a table that includes the field `Case #`. I have no control on how it's named. When I try to write a query, the # acts as a remark character and everything right of it is ignored.

Is there a way around this?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 03-25-04, 15:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
you are right, it is a very weird situation

urge you strongly to lobby to get the name changed

the only thing i was able to do was copy the contents into an identical table with a different name

first of all, i was not able to actually create a table this way

i had to fool it like this:
PHP Code:
create table badcolnames
id tinyint not null primary key auto_increment
, `Case 2integer not null
);
insert into badcolnames (`Case 2`)
values 937 )
, ( 
21 ) , ( 101010101 );

create table badcolnames2
select id
, `Case 2` as "Case #"
 
from badcolnames
 
select 
from badcolnames2 
 
id
,Case #
1,937
2
,21
3
,101010101 
against this table, nothing works except a plain SELECT *

so create and copy:
PHP Code:
create table badcolnames3
 
id3 integerCase3 integer )
 
insert into badcolnames3 
select 
*
 
from badcolnames2
 
 select 
from badcolnames3

id3
,Case3
1
,937
2
,21
3
,101010101 
totally weird
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On