Column update

Martooti

Member
Is there any chance I can add to the whole column full of values text at the begin?
I have a column with names of files. I would like to change that to path (add 'images/' at the begin of every value). And than to change element to fileupload element for creating values in the future.
Any suggestions?
Thanks in advance
 
And than to change element to fileupload element for creating values in the future.
Attention: this is only possible with a simple fileupload element (NO ajax upload, an ajax upload will use an additional repeat table).

You can do this directly in the DB with e.g. phpMyAdmin (best is to backup the table before trying)
UPDATE your-table SET your-element = CONCAT('images/', your-element)
 
I have got more advance issues now.
I have items that can be in many categories. Categories and subcategories are stored in separated table (cat id, parent id, cat name). In one more table is store connection between item and categories items belongs to.
I want to add category column to list of items. I have already a lot of data so I decide to make new field in items list called category where cat id will be stored. I tried to update the column using the formula above but it didn't work. I try: "UPDATE `itemstable` SET `category`= (SELECT `cat_id` FROM `categorytable` WHERE `secondtable.link_id`=`firsttable.link_id`) but it didn't work.
I guess the problem is this additional repeat table.
Is there a way to make it?
Eventually I want that the category element store cat id, but display cat names.
Since one item could have many categories I thought about making this element database join checkbox or multiselect.

Thank you for all advices
 
If you are adding a record into the table linking between items and categories then rather than an INSERT I think you will need to do an UPDATE query

Also I don't see you selecting "secondtable" or "firsttable" in your query, so your where statement is not going to work.

It also seems like you are duplicating data? If the item category relationship is stored in a table AND you are storing the categories in the item table? That sounds like it would cause problems with your data's integrity.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top