如何在c#中选择具有多个空格的列 [英] How to select columns with multiple spaces in c#

查看:92
本文介绍了如何在c#中选择具有多个空格的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择列中有多个空格的数据库列

I want to select database column which are having multiple spaces in column

Select  emp firstname lastname, id,branch(computer science as cse) from emptable



Emp firstname lastname 是一个带空格的列



请帮我


Emp firstname lastname is a column with spaces

Pls help me

推荐答案

首先这样做是不好的做法,但是如果你已经有了,那么

使用:



It's bad practice to do that in the first place, but if you've already had,
use:

Select 'emp firstname lastname', id,branch(computer science as cse) from emptable





干杯,

C



Cheers,
C


在SQL中,在包含空格的标识符周围放置方括号(包括列名,表名,触发器等。)



In SQL, put square braces around an identifier that has spaces in (this includes column names, table names, triggers, etc.)

Select  [emp firstname lastname], id,branch([computer science] as cse) from emptable





(更新:低于此值仅适用于SQL Server - 对于标准SQL,请使用双引号。)



(Update: per below this is for SQL Server only - for standard SQL use a double quote.)






命名一个表格列,例如计算机科学

不是很好的做法。



我建议例如ComputerScience



如果您设计了数据库,那么就该重新命名列了。



祝你好运,

Stephan
Hi,

naming a table column e.g. "Computer Science"
is not good practice.

I suggest e.g. "ComputerScience"

If you designed the database then it's time to rename the columns.

Best regards,
Stephan


这篇关于如何在c#中选择具有多个空格的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆