Tagged Questions
0
votes
1answer
54 views
Error “#1118 - row size too large” on the first row of the table only
I ran into a problem using a mySQL database. I have some columns as type text but when I try to enter data into the first row I get the error code "#1118 - Row size too large. The maximum row size for ...
2
votes
1answer
35 views
UPDATE table based on the same table
I have a table with product descriptions, and each product description has a product_id and a language_id. What I want to do is update all of the fields with a language_id of 2 to be equal to the same ...
0
votes
1answer
32 views
Is there a workaround for lack of support of cascade triggers with MySQL?
As things stand, cascaded foreign key actions do not activate triggers with MySQL. I don't want to get into the debate as to whether or not this is good, I just would like to know whether there is a ...
0
votes
1answer
23 views
MySQL-5.1 is not updating some rows with a simple UPDATE query [closed]
I'm trying to update a column in a table to be the same as the contents in the column of another table as part of a de-normalization process for a data warehouse project. The data is confidential, so ...
0
votes
1answer
57 views
Update one table from another table while sorting that table based on one column
This is the problem I'm trying to figure out in MySQL. We have an old table contains some forms submitted by our users. Somehow, the previous decision was each time a user comes to this survey, a new ...
0
votes
1answer
83 views
update column based on the sort order of another query
I'm trying to add arbitrarily ordered records to a database so that they can be sorted by the ui (or when I query the database ). My problem is I already have the list, and I need to add a default ...
0
votes
1answer
59 views
How to check which tables in DB (MYSQL) updated in last 1 hour / last 1 minute?
I have to create a xls datafeed for a website and I would like to know which tables are getting affected when I do a manual entry from CMS.
If i have installed fresh database and I'm doing first ...
0
votes
1answer
40 views
MySQL UPDATE statement using a table created on the fly
I want to update a table, say Table 1 using a table that I create on the fly (saytemp). To achieve this I have the following query:
UPDATE Table1 SET COUNT = temp.ctemp FROM ( SELECT A, SUM(UNO) AS ...
0
votes
1answer
89 views
On duplicate key do nothing
I am inserting into the following table using LuaSQL with PtokaX API.
CREATE TABLE `requests` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`ctg` VARCHAR(15) NOT NULL,
`msg` ...
0
votes
2answers
85 views
How do I fix the definer problem The user specified as a definer ('fred'@'192.168.0.%') does not exist
I dumped an existing database from my web site into a new MySQL setup on my laptop. Everything works except pages that use a view, when the error message above appears. There is only one view on the ...
0
votes
2answers
86 views
how to set a row's value from a certain row's value?
I have a MySQL table named "activities" with fields id(int), tstamp(timestamp), amount(decimal) balance(decimal). Decimal fields hold money values.
id tstamp amount balance
...
0
votes
1answer
209 views
Update to session table slow
I have a number of websites with session tables on a web server, these are used by Joomla CMS and Symfony framework systems. With slow_query_log=0.6, the update queries for the session tables come up ...
0
votes
2answers
171 views
How to do something like UPDATE DELAYED in MySQL
I have an averages table that should keep track of an average value over time. I don't want to have a row for each value, just a single row that continuously updates the average. What I've come up ...
1
vote
3answers
205 views
Problem with nested UPDATE queries
I cannot make an update query work. As a first step, the following one works correctly:
UPDATE Tab1
SET Tab1.a = '3'
WHERE
Tab1.id IN ( 123, 456 );
where id is the primary key of Tab1.
...
0
votes
3answers
173 views
INNER JOIN Giving time out on large database
Getting time out on this script
UPDATE
uk_data AS ud
INNER JOIN
uk_pc AS up
ON ud.cat10 = up.WardCode
SET
ud.cat8 = up.Latitude,
ud.cat9 = up.Longitude;
uk_pc Table ...
2
votes
1answer
126 views
How to re-assign two variables in a conditional UPDATE
Consider a simple update as
SET @var1 = 20;
SET @var2 = 26;
UPDATE table1 SET
col1=IF(@var1>50, @var1 := @var1-col4, @var1 := @var1+col5),
col2=IF(@var2>50, @var2 := @var2-col6, @var2);
...
1
vote
1answer
180 views
How to re-arrange rows to best fit within groups?
I categorized a table with the method introduced here to categorize my items to folders with a limit size of 100.
mixing_order id num_items cat order_in_cat cumulative_sum folder
1 ...
0
votes
1answer
188 views
How to UPDATE a column to SET previous row value to NULL cells?
I have a table as
id value
1 music
2
3 movie
4
5
6 book
7
8
Some values are missing, and I want to assign the value of previous row to produce
id value
1 music
2 music
3 movie
4 ...
0
votes
0answers
147 views
Can't UPDATE record with unique key [closed]
Im trying to do an UPDATE statement.
UPDATE `users` SET
`Email` = 'email@domain.com',
`Mobile` = '123456789',
`City` = 'Chicago',
`Firstname` = 'John',
`Lastname` = 'Smith',
`DOB` = '1980-01-01',
...
3
votes
1answer
126 views
A function to check if a column allows NULL
Is there a way to write an insert/update query that checks if a column allows NULLs: If it does set the column to NULL, and '' (empty string) otherwise?
I would be something like:
UPDATE mytable
...
3
votes
3answers
228 views
Update field with new string made from characters in existing value
field is meta_value and current value is like 01/01/2006
i want to change it to a string 20060101 so thought i could get the value and update it with the characters in the correct order.
ie
UPDATE ...
2
votes
1answer
125 views
I have to update all the rows of a Column in a table. Here is my query
So My tables are
People:
People_name(VARCHAR 100),
People_id (INT, PRIMARY KEY AUTO INCREMENT)
Tracks:
Track_id(INT PRIMARY KEY),
People_id_references (int ,Foreign key references ...
0
votes
0answers
112 views
Which update is faster using join or sequential?
My this question is in sequence of my previous question I asked.
I could write two solutions using Stored Procedure instead of trigger or nested-query .
Both use a helper function ...
2
votes
1answer
121 views
Update ranking on table
I have two tables:
mysql> desc rank ;
+----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
...
1
vote
2answers
417 views
GROUP BY two columns
I want to count two columns, but need to get the results of first column in one row.
SELECT country, COUNT(*)
FROM table1
GROUP BY country, type
This query gives me
country type COUNT(*)
...
4
votes
1answer
1k views
What's the most efficient way to batch UPDATE queries in MySQL?
I'm writing an application that needs to flush out a large number of updates to the database for an extended period of time, and I've gotten stuck at how to optimize the query. Currently I'm using ...
4
votes
2answers
175 views
fast bulk incrementing in MySQL
I have one big table foobar describing a many-to-many-relation and containing millions of foo's, millions of bar's and every bar having several hundereds of foo's -> billions of rows.
CREATE TABLE ...
1
vote
1answer
341 views
Why I cannot let EXPLAIN update statements?
I can imagine that it's actually more important to explain SELECT statements, but I wonder why there's no possibility to use EXPLAIN on UPDATEs/INSERTs. I may use a WHERE-statement in an UPDATE where ...
1
vote
4answers
10k views
How to update one table based on another table's values on the fly?
I have a table in the name of ips as below:
CREATE TABLE `ips` (
`id` int(10) unsigned NOT NULL DEFAULT '0',
`begin_ip_num` int(11) unsigned DEFAULT NULL,
`end_ip_num` int(11) unsigned DEFAULT ...
5
votes
1answer
2k views
Trigger to UPDATE after UPDATE?
I want to make a trigger to record the time of any update as
CREATE TRIGGER col_update
AFTER UPDATE ON col
FOR EACH ROW BEGIN
UPDATE col SET updated=NOW() WHERE id=NEW.id; // or OLD.id
END
The ...
3
votes
1answer
288 views
Update rank on a large table
I have a mysql table that has now 12 million records and I'm trying to update a column (rank) with the following UPDATE code:
SET @r=0;
UPDATE records SET rank= @r:= (@r+1) where type = 2 ORDER BY ...
0
votes
0answers
53 views
SQL to update incrementall
Have a table photos
photos.id
photos.user_id
photos.order
A) Is it possible via a single query to group all photos by user and then update the order 1,2,3..N ?
B) added twist, what if some of the ...
1
vote
1answer
145 views
extremely slow MyISAM slave updates
I have 2 slaves and one is working as expected. The other slave is extermely slow while executing the "update" statements. The insert and deletes are fast. I used "check table tbl_name" to see if any ...
1
vote
1answer
495 views
How should I update ID field values for all records based on previous values?
I need a SQL query that can update ID fields for all records in a table from their previous values to a new value based on that previous value.
For example, if the ID is 1, I want to change it to ...
4
votes
2answers
2k views
Update many rows in a table with a single statement?
What is the easiest way to update many rows in a table? I have a csv file that looks like this:
|primary_key |value|
| 1 | xyz|
| 2 | abc|
| 3 | def|
...
Rows with ...


