如果在Access中为空,则将字段从一列移动到另一列

时间:2013-10-18 00:59:33

标签: sql ms-access

下面是我正在使用的表格。我想从[Field1]列中取出字段并直接移到[Field2]列。

结果将是这样的

字段2

Browser
com.android.browser
com.android.browser.BrowserActivity

Email
com.android.email
com.android.email.activity.Welcome

Phone
com.android.contacts
com.android.contacts.activities.PCUDialtactsActivity

Gallery
com.android.gallery3d
com.android.gallery3d.app.Gallery

Tắt màn hình
com.katecca.screenofflockdonate
com.katecca.screenofflockdonate.MainHelper

Messaging
com.android.mms
com.android.mms.ui.ConversationList

Simple mode
com.pantech.app.skysettings.simplemode
com.pantech.app.skysettings.simplemode.simplemodesettingshrotcutActivity

enter image description here

1 个答案:

答案 0 :(得分:0)

这可能会满足您的需求:

SELECT iif(isnull(Field2), Field1, Field2) as [yourColumnTitle] 
FROM yourTableName

除此之外,你需要在表datatype = YesNo中添加一个列,并在你想要影响的行上将其设置为true,然后你可以

SELECT iif(NewColumn <> 0, Field1, Field2) as [yourColumnTitle]
FROM yourTableName