
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Insert Euro and Dollar symbol to a column in MySQL?
For this, use CASE statement with UPDATE command. Let us first create a table −
mysql> create table DemoTable1874 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Amount varchar(100) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1874(Amount) values('3450'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('190'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('7600'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('4500'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1874;
This will produce the following output −
+----+--------+ | Id | Amount | +----+--------+ | 1 | 3450 | | 2 | 190 | | 3 | 7600 | | 4 | 4500 | +----+--------+ 4 rows in set (0.00 sec)
Here is the query to insert Euro and Dollar symbol to a column in MySQL −
mysql> UPDATE DemoTable1874 SET Amount= CASE WHEN Id = 1 THEN Concat('$','',Amount) WHEN Id = 3 THEN Concat('€','',Amount) else Amount END ; Query OK, 2 rows affected (0.00 sec) Rows matched: 4 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1874;
This will produce the following output −
+----+---------+ | Id | Amount | +----+---------+ | 1 | $3450 | | 2 | 190 | | 3 | €7600 | | 4 | 4500 | +----+---------+ 4 rows in set (0.00 sec)
- Related Articles
- MySQL insert a value to specific row and column
- Is there a need to insert auto_increment column values in MySQL while using INSERT statement?
- Fetch the first letter of a column value and insert it in another column with MySQL
- Simple ways to insert delta symbol in Excel
- Simple ways to insert star symbol in Excel
- How to insert own values into auto_increment column in MySQL?
- How to remove dollar sign from a column of a data.table object in R?
- Insert NULL value into INT column in MySQL?
- How to insert DATE into a MySQL column value using Java?
- Copy values of one column to another using INSERT and SELECT in a single MySQL query
- How to insert only a single column into a MySQL table with Java?
- Matplotlib – How to insert a degree symbol into a Python plot?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- How can we insert current date automatically in a column of MySQL table?
- How do I insert multiple values in a column with a single MySQL query?

Advertisements