CONCAT equivalent in MS Access

孤街醉人 提交于 2019-11-27 14:51:06
UPDATE myTable
SET [My Column] = "Prefix " & [My Column] 
WHERE [Different Column]='someValue';

As far as I am aware there is no CONCAT

There are two concatenation operators available in Access: +; and &. They differ in how they deal with Null.

"foo" + Null returns Null

"foo" & Null returns "foo"

So if you want to update Null [My Column] fields to contain "Prefix " afterwards, use ...

SET [My Column] = "Prefix " & [My Column]

But if you prefer to leave it as Null, you could use the + operator instead ...

SET [My Column] = "Prefix " + [My Column]

However, in the second case, you could revise the WHERE clause to ignore rows where [My Column] contains Null.

WHERE [Different Column]='someValue' AND [My Column] Is Not Null

You can use the & operator:

UPDATE myTable
    SET [My Column] = "Prefix " & [My Column]
    WHERE [Different Column]='someValue';

Since there is no Concat function in MS-ACCESS, you can simply combine both strings with + operator:

  UPDATE myTable
 SET [My Column] = "Prefix " + [My Column]
 WHERE [Different Column]='someValue';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!