小编Jan*_*nty的帖子

如果表存在则删除表中的记录

我有很多删除查询,但在某些生产数据库中找不到某些表。我需要对这个问题做出简单的决定。

查询如

DELETE b.* FROM `table` b
JOIN `another_table` u
ON u.key2 = b.key
WHERE u.key3 <> ?
Run Code Online (Sandbox Code Playgroud)

我需要类似的东西:

IF TABLE `table` EXISTS DELETE b.* FROM `table` b ...
Run Code Online (Sandbox Code Playgroud)

mysql

5
推荐指数
1
解决办法
1万
查看次数

postgresql使用IF语句INSERT INTO

postgresql,如何从column.aINSERT中的column.b中的值来自同一个表Where

IF column.a = 1 then column.b = foo, 
IF column.a = 2 then column.b = bar,
IF column.a = 3 then column.b = good,
IF column.a = 4 then column.b = bad
Run Code Online (Sandbox Code Playgroud)

postgresql

1
推荐指数
1
解决办法
831
查看次数

将DataRow []转换为字符串数组会触发异常"无法将'System.Int32'类型的对象强制转换为'System.String'."

我需要一个DataRow [] drs第一列的字符串数组.我试过下面的一行代码,但它没有用.

DataTable中的数据类型是Int,我需要将它转换为字符串数组.

我错过了一些吗?请建议我.

DataRow[] drs = ds.Tables[1].Select();
Run Code Online (Sandbox Code Playgroud)

对不起,我需要一个列值来串行数组.

 string[] drsArray = drs
                .AsEnumerable()
         .Select(row => row.Field<string>("role_id")) //Here getting the exception
Run Code Online (Sandbox Code Playgroud)

我已经尝试了@Daniel的逻辑,它现在正在工作.现在是否有可能减少一些代码行.

 string[] drsArray = (drs
                        .AsEnumerable()
                 .Select(row => row.Field<int>("role_id"))
                 .Select(i => i.ToString()).ToArray());
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
622
查看次数

标签 统计

c# ×1

mysql ×1

postgresql ×1