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 > space in field name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-12-04, 02:44
greggyd greggyd is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
space in field name

Hi All,

I have an imported database with a field name as follows:

First name

So because it has a space between the words, I am having troubles writing a query for it. Does anybody know the syntax to do this? I tried the following with now luck:

Bring empty set even with a Joe in the table
SELECT * FROM table WHERE 'First name' = "Joe";

Same...
SELECT * FROM table WHERE "First name" = "Joe";

Gives error in syntax...
SELECT * FROM table WHERE First name = "Joe";

Any help would be appriciated.
Reply With Quote
  #2 (permalink)  
Old 03-12-04, 08:09
vududoc vududoc is offline
Registered User
 
Join Date: Jul 2001
Location: NC
Posts: 102
I suggest you remove the space in the field name (firstname) or replace the space with an underline (first_name).
Reply With Quote
  #3 (permalink)  
Old 03-12-04, 11:02
greggyd greggyd is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
space in first name

Thanks for the reply!

A good idea, but I'm not sure if I can rename it. The data is coming from a daily download from a MS SQL export to Excel with about 60 different fields. It would be extremely time comsuming to do on a daily basis. It's a pretty big database.

Is there some sort of script out ther to do this?
Reply With Quote
  #4 (permalink)  
Old 03-12-04, 12:32
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: space in field name

You need to use reverse quotes: `First Name`
Code:
SELECT * FROM table WHERE `First Name` = 'Joe';
Reply With Quote
  #5 (permalink)  
Old 03-12-04, 12:35
greggyd greggyd is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
space in field name

Ah! That did it!!!! Thanks!!
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