update

SQL Update query

Can i use several WHEN conditions in UPDATE clause to update a single column. I want to update table TABLE having columns ID and NAME: Is below query correct? UPDATE TABLE SET id = CASE id WHEN id IN (2, 3, 4) THEN 1 WHEN id= 5 THEN 8 WHEN id IN(9, 7) THEN 6 WHERE name = 'abc' ...

MySQL UPDATE - Selective update - continued

I have a query (source)... UPDATE covers t LEFT OUTER JOIN (SELECT cover_id FROM covers ORDER BY cover_views DESC LIMIT 10) c ON c.cover_id = t.cover_id SET cover_views = 0 WHERE c.cover_id IS NULL ...which resets all but the top 10 covers in the database to 0. I want to extend this to reset all covers bar the top ten per c...

Doctrine postSave, postUpdate and Internationalization (detect modification)

I'm having a little problem with a tables that are using the i18n behaviour on a Symfony 1.4 project that I'm developing. For example on the following model defined on YAML (I have others that follow the same pattern): Subject: actAs: Timestampable: ~ I18n: fields: [name] columns: name: { type: string(255), notnull...

Update OSGi bundle while starting

I have several OSGi bundles, each of which can be updated from an OSGi Bundle Repository. When I start my OSGi framework (Apache Felix), I want the first bundle to start and check for updates for all installed bundles. If updates are available, it should update each of them (including itself) then continue starting (or possibly shutdown,...

Updating multiple rows with different values

I got this table in my MySQL database, 'users'. It has the fields 'id' and 'value'. Now, I want to update lots of rows in this table with a single SQL query, but many rows should get a different value. Currently, I'm using this: UPDATE users SET value = CASE id WHEN 1 THEN 53 WHEN 2 THEN 65 WHEN 3 THEN 47 ...

Changing part of a composite-id

I have a class, BillMedicine, which is many-to-many table for Bill and Medicine. The BillMedicine mapping file is: <class name="BillMedicine" table="Bill_Medicine"> <composite-id> <key-many-to-one name="Bill" class="Bill" column="BillID" /> <key-many-to-one name="Medicine" class="Medicine" column="MedicineID" /> ...

How to update one table from another one without specifying column names?

I have two tables with identical structure and VERY LARGE number of fields (about 1000). I need to perform 2 operations 1) Insert from the second table all rows into the fist. Example: INSERT INTO [1607348182] SELECT * FROM _tmp_1607348182; 2) Update the first table from the second table but for update i can't found proper sql synt...

Update every column in every table

My database has recently been hacked by SQL injection leaving tags throughout data in all columns in all tables in my database. Is there a quick way of running a REPLACE UPDATE on all tables? Something like: UPDATE [all tables] SET [all columns]=REPLACE([all columns], '<script>....</script>', '') ...

Eclipse eRCP command framework - Unable to update command label dynamically

I've scoured the web for the entire day trying to find an example on how to implement what I read concerning changing a command label dynamically here: http:// wiki.eclipse.org/Platform_UI_Command_Design#Issue_102_-_Comm ands_implementation_of_label_changing I have the a command defined in my plugin.xml that uses the suggested schema: ...

Updating organic groups module in Drupal

Hi there, I've taken over a Drupal website. I'm trying to update the og module. It is currently version 1. I tried to upgrade it to the latest version but when I ran update.php it failed. So I thought I'd just try updating it to version 1.4. However, when I did this I then got the following errors when I ran update.php: # user warning...

PHP / Mongo: how do you update nested data?

I've been playing around with Mongo for about a week now and I still can't work out how to modify nested arrays in Mongo with php. So here is a sample document... array ( '_id' => new MongoId("4cb30f560107ae9813000000"), 'email' => '[email protected]', 'firstname' => 'Maurice', 'lastname' => 'Campobasso', 'password' =...

Grails: How to make a SAVE button inside the same table and make it work??

Hello there: I have the create inside the table/list that Grails provides. Here is a pictures of what I have As you can see, I create everything on the first row of my table, and then from the 2nd row and on is the actual list. In the last column of the 2nd row, you can see I have the UPDATE button and a delete button. The delete ...

Restful Rails Edit vs Update

I was trying to redirect to a different page after editing an entry, I assumed that it was using the update code because you are updating the database. It took me some time to realise that I was using the wrong action in the controller. Can someone please explain how edit and update work. Why are there two different actions? what are t...

WordPress: plugins don't load (only) on homepage after update

Hi there, After several plugins got updated yesterday I saw in the source code that actually no plugin is loaded(1) on the frontpage anymore. On all the other pages everything works just fine. The most obvious one is the menubar (wp-menubar-plugin), and for now I made an exception for the homepage(2) loading a hard coded copy of the me...

rails update redirecting to wrong controller

I have a model for a task which has a name, description, the process it belongs to, the position and a category. As there are only two different categories I have created additional controllers specific to the categories as they need to be treated differently. when i submit the edit form in one of the category controllers it is redirect...

Updating Value in a table

I want to achieve this .. update Table_A c set c.Column1 = (select d.column1 - b.column2 from Table_B d, Table_A b where b.primary_key = d.primary_key) But for outer query there is no primary key clause i have added.. How do i achieve it ...

Update with value from a select query in Linq To SQL

Update TableToBeUpdated Set ColumnNameId = (Select MasterColumnId from MasterTable where Id = @Id) Where ForeingKeyId = @Id AND AnotherColumn = @AnotherColumn How to achieve the above with one select statement and an update statement with a subquery? Currently what I'm thinking is. //First Select statement ...

Update rows in a related table based on condition in parent table.

I have a table TABLE1 (PARENT TABLE) with columns StaffID (PK) Name CategoryID (FK) I also have another related table TABLE2 (RELATED TABLE) with columns LeaveID (PK) StaffId (FK) StartDate What i want to do is write a T-SQL query to update StartDate column of all rows in TABLE2 whose CategoryID in TABLE1 = '3' TABLE2 is rela...

Access updatequery complains about uneditable query

I'm trying to run a very simple update query, like so: UPDATE tblSkuActueel INNER JOIN qrySkuTotaal ON tblSkuActueel.sku = qrySkuTotaal.sku SET tblSkuActueel.stock = [qryskutotaal].[stockaantal]; As you can see, it has to update the table. It should not have any problems doing so. Yet, I get the error message that I'm trying to edit ...

SQL field = other field minus an other ROW!

Table has 2 cols: [nr] and [diff] diff is empty (so far - need to fill) nr has numbers: 1 2 45 677 43523452 on the diff column i need to add the differences between pairs 1 | 0 2 | 1 45 | 43 677 | 632 43523452 | 43522775 so basically something like : update tbl set diff = @nr - @nrold where nr = @nr but i don't want...