Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add text to SQL Column

Tags:

sql

sql-update

I want to update 1 column in SQL Table. Example: Current value in column is like this

2013/09/pizzalover.jpg 
2013/10/pasta.jpg       

Now i want to update whole column like this : www.mypizza.com/2013/09/pizzalover.jpg Is there any way I can accomplish this? Thanks in advance

like image 358
user2829026 Avatar asked Sep 29 '13 18:09

user2829026


People also ask

How do I add data to an existing column in SQL?

If you want to add data to your SQL table, then you can use the INSERT statement. Here is the basic syntax for adding rows to your SQL table: INSERT INTO table_name (column1, column2, column3,etc) VALUES (value1, value2, value3, etc); The second line of code is where you will add the values for the rows.

How do you add text to a select statement?

To add/ concatenate text values within a select clause, you can use concat() function.


1 Answers

If you are using MYSql, you can use the concat() as :

update tableName set columnName= CONCAT('www.mypizza.com/', columnName);

SQLFiddle

If you are using oracle you can use the concatenation operator '||' as :

update tableName set "columnName"='www.mypizza.com/'||"columnName";

SQLFiddle

In SQL Server you can use + for string concatenation as:

update tableName set name='www.mypizza.com/'+columnName;

SQLFiddle

like image 67
heretolearn Avatar answered Oct 15 '22 02:10

heretolearn