sql-delete

how can I delete duplicates in SQLite?

房东的猫 提交于 2019-11-27 03:17:41
问题 I have a SQLite DB where the statement: SELECT messdatum, count(*) as anzahl from lipo GROUP BY Messdatum ORDER BY anzahl desc; results in some lines, which indicates that I have some duplicates with the same Messdatum . How can I delete the duplicates only form my sqlite db? (it should delete anzahl-1 records where the messdatum is the same?) Has anyone an advice? PS: I found this link How to remove duplicate from Microsoft but have problems with sqlite dialect. I got some errors due to the

Google BigQuery Delete Rows?

こ雲淡風輕ζ 提交于 2019-11-27 01:20:23
问题 Anyone know of any plans to add support for delete parts of data from a table in Google Bigquery? The issue we have right now is we are using it for analytics of data points we collect over time. We want to run the queries over the last X days of data, however after the last X days of data we no longer need to store the data in BigQuery. The only way currently we can think of to delete the data would be to delete the entire table of data, then recreate it and load it with X number of days of

Deleting rows from SQLite table when no match exists in another table

感情迁移 提交于 2019-11-27 01:18:45
问题 I need to delete rows from an SQLite table where their row IDs do not exist in another table. The SELECT statement returns the correct rows: SELECT * FROM cache LEFT JOIN main ON cache.id=main.id WHERE main.id IS NULL; However, the delete statement generates an error from SQLIte: DELETE FROM cache LEFT JOIN main ON cache.id=main.id WHERE main.id IS NULL; The error is: SQLite Error 1 - near "left": syntax error. Is there another syntax I could use? 回答1: SQLite apparently doesn't support joins

Pros & Cons of TRUNCATE vs DELETE FROM

帅比萌擦擦* 提交于 2019-11-27 00:40:19
问题 Could someone give me a quick overview of the pros and cons of using the following two statements: TRUNCATE TABLE dbo.MyTable vs DELETE FROM dbo.MyTable It seems like they both do the same thing when all is said and done; but are there must be differences between the two. 回答1: TRUNCATE doesn't generate any rollback data, which makes it lightning fast. It just deallocates the data pages used by the table. However, if you are in a transaction and want the ability to "undo" this delete, you need

Best way to delete millions of rows by ID

时间秒杀一切 提交于 2019-11-27 00:12:35
I need to delete about 2 million rows from my PG database. I have a list of IDs that I need to delete. However, any way I try to do this is taking days. I tried putting them in a table and doing it in batches of 100. 4 days later, this is still running with only 297268 rows deleted. (I had to select 100 id's from an ID table, delete where IN that list, delete from ids table the 100 I selected). I tried: DELETE FROM tbl WHERE id IN (select * from ids) That's taking forever, too. Hard to gauge how long, since I can't see it's progress till done, but the query was still running after 2 days. Just

How to delete and update a record in Hive

风流意气都作罢 提交于 2019-11-26 23:49:58
I have install Hadoop, Hive, Hive JD BC. which are running fine for me. But I still have a problem. How to delete or update a single record using Hive because delete or update command of MySQL is not working in hive. Thanks hive> delete from student where id=1; Usage: delete [FILE|JAR|ARCHIVE] <value> [<value>]* Query returned non-zero code: 1, cause: null Charles Menguy You should not think about Hive as a regular RDBMS, Hive is better suited for batch processing over very large sets of immutable data. The following applies to versions prior to Hive 0.14, see the answer by @ashtonium for

MySQL Getting around error 1093

百般思念 提交于 2019-11-26 23:38:36
问题 Error 1093 states that you can't UPDATE or DELETE using a subquery if your subquery queries the table you are deleting from. So you can't do delete from table1 where id in (select something from table1 where condition) ; Ok, what's the best way to work around that restriction, (assuming you really do need to subquery to perform the delete and cannot eliminate the self referencing subquery entirely?) Edit: Here's the query for those who are interested: mysql> desc adjacencies ; +---------+----

MySQL Injection - Use SELECT query to UPDATE/DELETE

不问归期 提交于 2019-11-26 23:21:50
问题 I've got one easy question: say there is a site with a query like: SELECT id, name, message FROM messages WHERE id = $_GET['q'] . Is there any way to get something updated/deleted in the database (MySQL)? Until now I've never seen an injection that was able to delete/update using a SELECT query , so, is it even possible? 回答1: If you say you use mysql_query that doesn't support multiple queries, you cannot directly add DELETE / UPDATE / INSERT , but it's possible to modify data under some

SQL DELETE with INNER JOIN

核能气质少年 提交于 2019-11-26 22:21:47
问题 There are 2 tables, spawnlist and npc , and I need to delete data from spawnlsit . npc_templateid = n.idTemplate is the only thing that "connect" the tables. I have tried this script but it doesn't work. I have tried this: DELETE s FROM spawnlist s INNER JOIN npc n ON s.npc_templateid = n.idTemplate WHERE (n.type = "monster"); 回答1: Add .* to s in your first line. Try: DELETE s.* FROM spawnlist s INNER JOIN npc n ON s.npc_templateid = n.idTemplate WHERE (n.type = "monster"); 回答2: If the

Deleting multiple rows using checkboxes, PHP and MySQL

我的梦境 提交于 2019-11-26 21:58:21
问题 As the title suggests I want to delete multiple rows from my database. To accomplish this I have two files, a front end file that generates a table that shows the files a user may delete which are chosen using checkboxes. The back end file is to process the selected checkboxes and use an SQL statement to delete the chosen files. The problem I am having is passing the id of a selected file from the front end to the back. The code for both files are below: Front End //Build Table Query $query=