MYSQL将Date列作为字符串 [英] MYSQL get Date column as string
本文介绍了MYSQL将Date列作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All
我不确定我的问题是否有答案!
我有一个带日期列的MYSQL表。我希望在C#中获取它作为字符串而不是MYSQL日期时间
但问题是我不知道列名。我知道如果知道列名怎么做
Hello All
I am not sure my question has answer!
I have a MYSQL table with a date column. I want get it in C# as string not MYSQL date time
but matter is I don't know column Name.I know how do it if know column name
SELECT DATE_FORMAT(X, '%Y/%m/%d') AS X FROM Y
但是当我不知道列名时我不知道怎么办?
but i don't know how do it when i don't know column Name?
推荐答案
我假设你知道表名,然后您可以找到包含列名称及其数据类型的表结构:
I assume you know the table name, then you can find out the table structure with column names and their data types:
show columns from databasename.tablename;
选择转换(varchar(50),x)作为x从y
如果日期列为null然后使用它,
选择isnull(convert(varchar(50),x),' - ')作为x从y
如果有效,那么请接受它指定费率。
thnx
select convert(varchar(50), x) as x from y
if date column is null then use this,
select isnull(convert(varchar(50),x) , '-') as x from y
if its works, then plz accept it n assign rates.
thnx
这篇关于MYSQL将Date列作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文