sql-update

ERROR [22P02] ERROR: invalid input syntax for integer: “”;

穿精又带淫゛_ 提交于 2019-12-22 06:49:38
问题 Never seen such error: ERROR [22P02] ERROR: invalid input syntax for integer: ""; Error while executing the query Creating table: Public Function PrimkCreate(ByVal myPrimkTable As String, ByVal nCon As OdbcConnection) As Integer Dim ans As Integer Dim cCommand As OdbcCommand = New OdbcCommand("CREATE TABLE IF NOT EXISTS " + myPrimkTable + "(" & _ "prm_id int NOT NULL, " & _ "pkni text, " & _ "pdatum text, " & _ "pdatumnaplate text, " & _ "pdanaodgode int, " & _ "puldok text, " & _ "puldokbroj

Why become referential constraints inconsistent after updating foreign key?

一世执手 提交于 2019-12-22 06:44:36
问题 Sorry for the nebulous title, it's hard to describe this in a single line: I have 2 entities User and UserAddress , where User has 2 foreign keys DefaultInvoiceAddressId and DefaultDeliveryAddressId and UserAddress has a UserId foreign key. The user object has navigation properties for the default addresses ( DefaultInvoiceAddress and DefaultDeliveryAddress ) as well as one for all of his addresses: AllAddresses . The mapping etc. works, creating and updating users and addresses works too.

Too many bind arguments. 5 arguments were provided but the statement needs 4 arguments

谁都会走 提交于 2019-12-22 04:11:09
问题 I get the IllegalArgumentException above when executing the function below. What I don't get is that when I run the debugger, the values variable clearly only contains 4 arguments, as it should. So... (1) Where does this mysterious fifth argument come from? (2) How should I approach finding this error? db.update( UppdragEntry.TABLE_NAME, values, selection, selectionArgs); 回答1: Selection contains the following: String selection = "_id"; String[] selectionArgs = {" =" + personId}; You have a

mysql + update top n

两盒软妹~` 提交于 2019-12-22 04:07:57
问题 I've got a query like this: update table set status = 1 where status = 2; but I'd only like to do this to the top 400. I tried adding a 'limit 0, 400' (like I would in a query) but that didn't work. I did some searching and mysql doesn't seem to support the TOP(n) command as sql server does. Any idea how I'd do this? edit: for future reference, I was using the following style for selects, which worked fine: select * from table where ... limit 0, 400; but in the update it wouldn't work with

How to view/edit/delete records from a checklist table in php/mysql

一曲冷凌霜 提交于 2019-12-22 00:32:49
问题 I've built a checklist table in php, the data gets saved in a mysql database table. With the below code, the data gets saved in the database, now I want to be able to edit and delete the records. The database table has two columns - auto-increment Id and ColRow which has the values of the checked boxes. The values are fetched from the different tables of the database. The header and the first columns are fetched from two tables which gets saved in the report table depending on the boxes being

update a database table field with comma separated list from join

纵饮孤独 提交于 2019-12-21 15:24:13
问题 I have two tables named Districts and Schools . The Districts table contains a column named Schools . I need to populate the Schools column of the Districts table from the corresponding Schools table, so that each row in the Districts table has a comma separated list of values of school names from the Schools table. How can I do this? Should I use an UPDATE query or a stored procedure? I only got as far as: SQL Fiddle Districts Table +------------+------+---------+ | DistrictId | Name |

Update multiple rows with different values in SQL

帅比萌擦擦* 提交于 2019-12-21 11:55:34
问题 I have a table like this: SKU Size A 10 B 10 C 10 D 10 E 10 F 10 G 10 I want to change it to: SKU Size A 20 B 10 C 30 D 10 E 80 F 10 G 60 I have more than 3000 rows of records to update. How can I do that with SQL update command ? 回答1: UPDATE T SET Size = CASE SKU WHEN 'A' THEN 20 WHEN 'B' THEN 10 WHEN 'C' THEN 30 WHEN ... END Or there may be a formula for calculating the size, but you've failed to give it in your question (Or we may have to switch to a more complex CASE expression, but again

MYSQL - Changing year of dates from 2020 to 2011

旧时模样 提交于 2019-12-21 08:24:16
问题 I have bunch of dates in format YYYY-MM-DD But I have all year in 2020-MM-DD I want to change it to 2011-MM-DD How can I achieve this ? 回答1: UPDATE YourTable SET YourDateColumn = SUBDATE(YourDateColumn, INTERVAL 9 YEAR); 回答2: USE ADDDATE(old_date, INTERVAL -9 YEAR) 回答3: UPDATE YourTable SET YourDateColumn = ADDDATE(YourDateColumn, INTERVAL 1 YEAR) WHERE YourDateColumn >= '2010-01-01' AND YourDateColumn <= '2010-12-31'; If your table down not have an index on the date field, you could get away

MYSQL - Changing year of dates from 2020 to 2011

旧街凉风 提交于 2019-12-21 08:22:18
问题 I have bunch of dates in format YYYY-MM-DD But I have all year in 2020-MM-DD I want to change it to 2011-MM-DD How can I achieve this ? 回答1: UPDATE YourTable SET YourDateColumn = SUBDATE(YourDateColumn, INTERVAL 9 YEAR); 回答2: USE ADDDATE(old_date, INTERVAL -9 YEAR) 回答3: UPDATE YourTable SET YourDateColumn = ADDDATE(YourDateColumn, INTERVAL 1 YEAR) WHERE YourDateColumn >= '2010-01-01' AND YourDateColumn <= '2010-12-31'; If your table down not have an index on the date field, you could get away

MySQL InnoDB SELECT…LIMIT 1 FOR UPDATE Vs UPDATE … LIMIT 1

微笑、不失礼 提交于 2019-12-21 07:47:41
问题 I have a table v_ext in a MySQL with InnoDB engine: - id: primary key - code: pre-generated list of codes (say 1000 codes are generated randomly) - user_id: initially NULL When a user purchase an item, they receive a code. I need to update the table to populate the user_id column. I have two options: START TRANSACTION; SELECT id FROM v_ext WHERE user_id IS NULL LIMIT 1 FOR UPDATE; -- return id 54 for ex. UPDATE v_ext SET user_id=xxx WHERE id=54; COMMIT; or UPDATE v_ext SET user_id=xxx WHERE