Hi,
thsi can be a solution, there are others :
mysql> select substring(id,1,2), substring(id,3,length(id)) from mytable;
+-------------------+----------------------------+
| substring(id,1,2) | substring(id,3,length(id)) |
+-------------------+----------------------------+
| UP                | 05000                      |
| UP                | 05001                      |
| UP                | 05002                      |
| UP                | 05003                      |
| UP                | 05004                      |
+-------------------+----------------------------+
5 rows in set (0.01 sec)

mysql>
mysql>
mysql> update mytable set id=concat('EN',substring(id,3,length(id)));
Query OK, 5 rows affected (0.03 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> select * from mytable;
+---------+
| id      |
+---------+
| EN05000 |
| EN05001 |
| EN05002 |
| EN05003 |
| EN05004 |
+---------+
5 rows in set (0.00 sec)


Mathias

Selon Scott Purcell <[EMAIL PROTECTED]>:

> Hello,
>
> I have a table that has a varchar column in which I need to change a prefix
> for all records. Currently there are about 500 records and I did not want to
> do this by hand. It looks like this:
>
> [data here ]
> UP05000
> UP05001
> UP05002
> UP05003
>
> The identifier has now changed to EN so each records needs to be
> EN05000
> EN05001
> EN05002
> etc.
> Can this be done with a query syntax? Or do I need to do this manually.
>
> Thanks,
> Scott
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to