Combine rows / concatenate rows

后端 未结 5 2148
旧巷少年郎
旧巷少年郎 2020-11-22 16:53

I\'m looking for an Access 2007 equivalent to SQL Server\'s COALESCE function.

In SQL Server you could do something like:

Person

<         


        
5条回答
  •  猫巷女王i
    2020-11-22 17:20

    I understand here that you have a table "person" with 3 records. There is nothing comparable to what you describe in Access.

    In "standard" Access (DAO recordset), you will have to open a recordset and use the getrows method to have your data

    Dim rs as DAO.recordset, _
        personList as String, _
        personArray() as variant
    
    set rs = currentDb.open("Person")
    set personArray = rs.getRows(rs.recordcount)
    
    rs.close
    

    once you have this array (it will be bidimensional), you can manipulate it to extract the "column" you'll need. There might be a smart way to extract a one-dimension array from this, so you can then use the "Join" instruction to concatenate each array value in one string.

提交回复
热议问题