strSQL = "INSERT INTO MEMBER (" & _
"MERCHANT_UID, MEMBER_ID, ACCOUNT_ID, LOGIN_PWD, SALUTATION, FULL_NAME, " & _
"IC_NO, DOB, GENDER, NATIONALITY, CITY, STATE, " & _
"COUNTRY, POSTCODE, PHONE_MOBILE, PHONE_HOUSE, PHONE_OFFICE, EMAIL, SOURCE, IS_REQ_CHG_PWD, " & _
"ADDRESS_1, ADDRESS_2, ADDRESS_3, " & _
"CREATED_BY, CREATED_DATETIME, " & _
"MODIFIED_BY, MODIFIED_DATETIME) " & _
"VALUES (" & _
"@MERCHANT_UID, @MEMBER_ID, @ACCOUNT_ID, @LOGIN_PWD, @SALUTATION, @FULL_NAME, " & _
"@IC_NO, @DOB, @GENDER, @NATIONALITY, @CITY, @STATE, " & _
"@COUNTRY, @POSTCODE, @PHONE_MOBILE, @PHONE_HOUSE, @PHONE_OFFICE, @EMAIL, @SOURCE, @IS_REQ_CHG_PWD, " & _
"@ADDRESS_1, @ADDRESS_2, @ADDRESS_3, " & _
"@CREATED_BY, @CREATED_DATETIME, " & _
"@MODIFIED_BY, @MODIFIED_DATETIME);"
上面是表1,它是成员表。表2将是member_activation表中的Account_ID_Format(字段名称)
我想将上述查询中的account_ID_Format插入表2。我该怎么做?
最佳答案
您可以通过这种方式使用insert select语句
INSERT INTO tablename (columnname1,columnname2,..) SELECT columnname1,columnname2,.. FROM tablename2 WHERE id = 4
这会做的工作
INSERT INTO members (account_ID_Format) SELECT account_ID_Format FROM members_activation WHERE id = 4