Flo
Flo

Reputation: 1445

Join strings in sql update query

I have two fields with a string in it, and I want a combination of those in a third field like:

UPDATE table SET field3=field1 . '_' . field2

What would be the right syntax for that?

It is MySQL.

Okay that CONCAT Thing worked, is there a function to convert those fields to lowercase?

Upvotes: 1

Views: 1514

Answers (2)

David Espart
David Espart

Reputation: 11780

It depends on the database management system. In sql server would be:

UPDATE table SET field3 = field1 + '_' + field2

Whereas in Mysql it can be done with:

UPDATE table SET field3 = CONCAT_WS ('_', field1, field2)

Upvotes: 2

Philip Kelley
Philip Kelley

Reputation: 40309

In SQL Server:

UPDATE table SET field3 = field1 + '._.' + field2

Upvotes: 1

Related Questions