简体   繁体   中英

How can I reference a column with a space in the name?

I'm trying to run a statement where I retrieve tuples from a database. However my attribute has a space which is "State Name".

Im calling the SQL statement as follows:

select * from States where State Name = 'Michigan';

I'm pretty sure there is something wrong with the attribute having a space. How can I fix this problem without changing the name of the attribute? How can I call a SQL statement with the attribute constraint having a space?

Thanks,

select * from States where [State Name] = 'Michigan';

尝试在其周围抛出方括号:

select * from States where [State Name] = 'Michigan';

The Standard SQL delimiter (and supported by SQL Server) is the double quote eg

SELECT * 
  FROM States 
 WHERE "State Name" = 'Michigan';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM