Matthew Stuart wrote:
> I have a DB that has a field in it that currently just holds single or
> double numbers - these numbers are basically a reference to a category
> in which the particular record should be displayed. However I have now
> been asked if I can make it so that a particular record can be displayed
> in more than one category.
>
> All I need to do is somehow ask the field to add a forward slash to the
> front and end of the data, so the data will go from this:
>
> 1
> 33
> 21
> 9
> 11
>
> to this:
>
> /1/
> /33/
> /21/
> /9/
> /11/
>
> How do I get MySQL to do this? I guess I might have to do it in two
> steps by firstly adding the slash to the front and then lastly to the
> back. But I have no idea on how to do it. My reason for doing this is so
> that I get the webpage to look for numbers that are between the slashes.
> this will enable me to have numbers like this: /1/33/9/ enabling me to
> have a record in more than one category.
>
> Any help would be appreciated.
>
> Thanks
>
> Mat
>
> --MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql> To unsubscribe: http://lists.mysql.com/mysql?unsub=1>
actually, forgot to answer on your question:
if your table name is your_table and column with categories is named
categories:
UPDATE your_table SET categories=CONCAT('/', categories, '/');
it will update your whole table at once.
-afan

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.