Bun
Bun

Reputation: 73

Combine attributes using sql vba access

I have a sql statement that want to combine FirstName and LastName together while a listbox retrieve from a table.

rs.open"Select ID,Join(FirstName,LastName),Sex from TblPerson "
Set listbox.Recordset=rs

I know i use Join() it's wrong, but i just want to explain my purpose. Thank you in advanced !!

Upvotes: 0

Views: 46

Answers (1)

Rick
Rick

Reputation: 1913

You can concatenate with code like this:

"SELECT ID, FirstName + ' ' + LastName AS FullName, Sex FROM TblPerson"

If you are using SQL Server 2012 or higher then this will also work (based on your "access" tag, I assume you aren't):

"SELECT ID, CONCAT(FirstName, ' ', LastName) AS FullName, Sex FROM TblPerson"

Upvotes: 1

Related Questions