& or + to join fields/text?
-
Hi, Please refresh my memory... What the difference is between using & or + to join fields with text. SELECT FirstName + ' ' + LastName AS FullName FROM table or SELECT FirstName & ' ' & LastName AS FullName FROM table thanks, Ron
-
Hi, Please refresh my memory... What the difference is between using & or + to join fields with text. SELECT FirstName + ' ' + LastName AS FullName FROM table or SELECT FirstName & ' ' & LastName AS FullName FROM table thanks, Ron
myNameIsRon wrote:
SELECT FirstName + ' ' + LastName AS FullName FROM table
This works
myNameIsRon wrote:
SELECT FirstName & ' ' & LastName AS FullName FROM table
This doesn't, you get Invalid operator for data type. Operator equals boolean AND, type equals varchar.
Bob Ashfield Consultants Ltd
-
myNameIsRon wrote:
SELECT FirstName + ' ' + LastName AS FullName FROM table
This works
myNameIsRon wrote:
SELECT FirstName & ' ' & LastName AS FullName FROM table
This doesn't, you get Invalid operator for data type. Operator equals boolean AND, type equals varchar.
Bob Ashfield Consultants Ltd
Hmmm, Both will work for me. I'm using a MS Access db with OleDbCommand (C#) Ron
-
Hmmm, Both will work for me. I'm using a MS Access db with OleDbCommand (C#) Ron
Both do not work on SQL Server. Access has its own brand of SQL and does a lot of wierd stuff.
-
Hmmm, Both will work for me. I'm using a MS Access db with OleDbCommand (C#) Ron
-
Hmmm, Both will work for me. I'm using a MS Access db with OleDbCommand (C#) Ron
Thanks guys, I didn't realize it was specific to Access SQL. I did some testing, and here it is. If your field is NULL, and you're using '+', the join is ignored. SELECT ID_Field + ' - ' & NameField FROM table ID_Field not null: 3433 - Bob Smith ID_Field null: Bob Smith SELECT ID_Field & ' - ' & NameField FROM table ID_Field not null: 3433 - Bob Smith ID_Field null: - Bob Smith Ron
-
Hi, Please refresh my memory... What the difference is between using & or + to join fields with text. SELECT FirstName + ' ' + LastName AS FullName FROM table or SELECT FirstName & ' ' & LastName AS FullName FROM table thanks, Ron