如何在查询两列时在查询中给出空格 [英] how to give space in query while concating two columns

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

问题描述

嗨朋友们,



我在使用Gridview工作在asp.net c#上工作。



我有我的数据库表中的数据,并在gridview中显示。



这里我想用空格连接两列。



这是我的代码



从ScheduleTable中选择(TrainCode + TrainName)为TrainNo



它显示MM2687,所以我需要它作为MM 2687

我需要在TrainCode和Train Name之间留一个空格。



请帮助



谢谢

Hi friends,

Iam working on asp.net c# using Gridview.

I have data in my database table, and am displaying in gridview.

here i want to concat two columns using space.

This is my code

Select (TrainCode + TrainName) as TrainNo from ScheduleTable

It displays MM2687 , so i need it as MM 2687
I need a single space between TrainCode and Train Name.

Please help

Thanks

推荐答案

试试这样

Try like this
SELECT  [TrainCode] + ' ' + [TrainName] as TrainNo  FROM ScheduleTable



这可能有效。


This may work.


这篇关于如何在查询两列时在查询中给出空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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