sql-update

PostgreSQL: update with left outer self join ignored

限于喜欢 提交于 2019-12-23 19:58:45
问题 I want to update the column leaf_category with TRUE where the category is not a parent category. It works as a select statement: select c1.id, c1.name, c1.slug, c1.level, c2.parent_id, c2.name, c2.slug, c2.level from catalog_category c1 left outer join catalog_category c2 on (c1.id = c2.parent_id) where c2.parent_id is null; However, the corresponding UPDATE sets all the columns to TRUE . update catalog_category set leaf_category = True from catalog_category c1 left outer join catalog

How the schema migration tools work?

旧街凉风 提交于 2019-12-23 18:05:25
问题 I have db based application and I delete the schema & db content every time whenever there is any changes in the schema. Now it is in development mode. Soon we release the application in production. But we suspect there could be many changes after we release the application in production use. The software shall be installed on many locations across the globe. (Not a web based app) How the schema migration tool work in this case? or How can we use them in typical database based applications

How to update multiple columns in mysql using php

两盒软妹~` 提交于 2019-12-23 12:43:12
问题 Here i am trying to update update multiple column values in mysql table using php. $product_id = mysqli_real_escape_string($link, $_POST['product_id']); $product_name = mysqli_real_escape_string($link, $_POST['product_name']); $product_category = mysqli_real_escape_string($link, $_POST['product_category']); $sql = "UPDATE product_list (product_name, product_category, product_price,product_description,product_size_category) VALUES ('$product_name', '$product_category', '$product_price', '

Update a Table Field to its Value Plus a Constant on MYSQL w/o PHP

余生颓废 提交于 2019-12-23 11:13:32
问题 I would like to perform an UPDATE in MYSQL in which I take a field value, add a constant and save the new value in the same field. Let's assume that we have a column called OldValue in a table called aTable . Pseudocode could be: UPDATE aTable SET OldValue = OldValue + 220 WHERE someField = someValue Do you have any idea on how I could do that? I would like to use a single query (on some administration panel) without making a php script. (Of course, in that case the answer is quite simple.)

SQL UPDATE read column values before setting

。_饼干妹妹 提交于 2019-12-23 10:05:56
问题 I have searched for this information both on SO and on google, but have not found any authoritative answer. When you have an update statement like: UPDATE table SET rowA = rowB, rowB = NULL ... It seems that: ordering is not important ( UPDATE table SET rowB = NULL, rowA = rowB ) nonetheless, the result is that rowA takes the prev value in rowB, because it seems that UPDATE first reads the previous values, then it updates them. I would like to know if the two above points are true in general

Update column with value from another table using SQLite?

主宰稳场 提交于 2019-12-23 09:57:21
问题 I have two SQLite tables. I want to update a column in table1 with a value from table2 . Table 1, table1 (id INTEGER AUTOINCREMENT, status TEXT, name TEXT); : | id | status | name | |----|-----------|------| | 1 | pending | xyz | | 2 | completed | abc | Table 2, table2 (status TEXT, name TEXT, trans_id INTEGER); : | trans_id | status | name | |----------|-----------|------| | 1 | refunded | cvb | | 2 | cancelled | asd | I want to update status and name from table2 to table1 where table1.id =

Do you only update the changed fields or all the fields?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 07:22:56
问题 I'm wondering if it's worth the server time when updating a record to retrieve the existing record, loop through the fields checking for changes and only putting the changed fields in the update query? (I am using MySQL & PHP.) The main reason for doing this is to reduce the size of the update query for change log purposes. Normally the query might have 15 fields, but only 2 fields are actually being changed. This query can then also be used for logging as it will only contain the changed

SQL Server - How to Hint an Index on an Update command?

梦想与她 提交于 2019-12-23 07:21:51
问题 I'm trying to execute the following command to force an update to use a non-clustered index: UPDATE Flights SET Airtime=5555678 WHERE Distance=10000 OPTION (TABLE HINT(Flights, INDEX (DistanceIndex))) ... and it's erroring: Msg 8724, Level 16, State 1, Line 75 Cannot execute query. Table-valued or OPENROWSET function 'Flights' cannot be specified in the TABLE HINT clause. I can't find any clear advice on how the syntax should be properly formed inside the TABLE HINT statement. Please can

Sql update query doesn't fire update trigger for all records

半城伤御伤魂 提交于 2019-12-23 06:14:56
问题 I called update query from table1 trigger, when that query runs, it updates other table2 successfully but update trigger of table2 is fired only 1 time means not for every record that was updated from query of update I'm using SQL Server 2008 Express edition- Please guide me where I am wrong 回答1: Finally got the anwser :/, Trigger fire once for single query execution. mass or bulk update/insert/delete will not awake trigger for every row :(, i really appreciate Mr. Markov & Mr. David Dubois,

PHP MySQL Update Set query with Multiple columns

佐手、 提交于 2019-12-23 05:43:07
问题 I've tried this query with both commas and "AND" statements as pictured below. I get a syntax error Something went wrong.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'are available 24/7 by phone and email to answer any questions and to assist you ' at line 1 every time I try this query: $sql = mysql_query("UPDATE general SET bookabandheading = $_POST[bookabandheading AND bookaband = $_POST[bookaband] AND