sql-delete

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

ε祈祈猫儿з 提交于 2019-11-28 06:22:29
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? wimvds SQLite apparently doesn't support joins with the delete statement, as you can see on the Syntax diagrams . You should however be able to use

Pros & Cons of TRUNCATE vs DELETE FROM

无人久伴 提交于 2019-11-28 04:49:16
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. dcp 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 to use DELETE FROM , which gives the ability to rollback. EDIT: Note that the above is incorrect for

Delete all rows with timestamp older than x days

两盒软妹~` 提交于 2019-11-28 04:19:36
I want to delete all the rows with timestamp older than 180 days from a specific table in my database. I've tried the this: DELETE FROM on_search WHERE search_date < DATE_SUB(NOW(), INTERVAL 180 DAY); But that deleted all the rows and not only the rows older than 6 months. I have a column in on_search table called search_date and contains the time when that row was created. search_id search_term search_date 660779 car games 1390052553 JSR DELETE FROM on_search WHERE search_date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY)) DELETE FROM on_search WHERE search_date < NOW() - INTERVAL N DAY

java.lang.IllegalArgumentException: Removing a detached instance com.test.User#5

て烟熏妆下的殇ゞ 提交于 2019-11-28 03:47:56
I have a java EE project using JPA (transaction-type="JTA"), hibernate as provider. I write my beans to handle the CRUD things. The program running in JBOSS 7 AS. I have an EntityManagerDAO : @Stateful public class EntityManagerDao implements Serializable { @PersistenceContext(unitName = "dtdJpa") private EntityManager entityManager; @TransactionAttribute(TransactionAttributeType.REQUIRED) public Object updateObject(Object object) { object = entityManager.merge(object); return object; } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void createObject(Object object) {

Faster way to delete matching rows?

倖福魔咒の 提交于 2019-11-28 03:39:02
I'm a relative novice when it comes to databases. We are using MySQL and I'm currently trying to speed up a SQL statement that seems to take a while to run. I looked around on SO for a similar question but didn't find one. The goal is to remove all the rows in table A that have a matching id in table B. I'm currently doing the following: DELETE FROM a WHERE EXISTS (SELECT b.id FROM b WHERE b.id = a.id); There are approximately 100K rows in table a and about 22K rows in table b. The column 'id' is the PK for both tables. This statement takes about 3 minutes to run on my test box - Pentium D, XP

Deleting millions of rows in MySQL

做~自己de王妃 提交于 2019-11-28 03:22:38
I recently found and fixed a bug in a site I was working on that resulted in millions of duplicate rows of data in a table that will be quite large even without them (still in the millions). I can easily find these duplicate rows and can run a single delete query to kill them all. The problem is that trying to delete this many rows in one shot locks up the table for a long time, which I would like to avoid if possible. The only ways I can see to get rid of these rows, without taking down the site (by locking up the table) are: Write a script that will execute thousands of smaller delete

Deleting multiple rows using checkboxes, PHP and MySQL

孤街浪徒 提交于 2019-11-28 01:40:26
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="SELECT * FROM documents"; $result= mysqli_query($con, $query) or die("Invalid query"); $count = mysqli

Delete Request With header and Parametes Volley

☆樱花仙子☆ 提交于 2019-11-28 01:21:49
Hi i want to Send Delete Request to server using Volley along Headers and body parameters. but i am not able to send request successfully What i have tried JSONObject jsonbObjj = new JSONObject(); try { jsonbObjj.put("nombre", Integer.parseInt(no_of_addition .getText().toString())); jsonbObjj.put("cru", crue); jsonbObjj.put("annee", 2010); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } VolleyRequest mVolleyRequest = new VolleyRequest( Method.DELETE, url, jsonbObjj, new Listener<JSONObject>() { @Override public void onResponse(JSONObject jsonObject) { //

MySQL Injection - Use SELECT query to UPDATE/DELETE

若如初见. 提交于 2019-11-28 00:01:24
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? a1ex07 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 circumstances. For example, let's say you have the following function DELIMITER // CREATE DEFINER=`root`@

MySQL LIMIT on DELETE statement

♀尐吖头ヾ 提交于 2019-11-27 21:46:36
I put together a test table for a error I recently came across. It involves the use of LIMIT when attempting to delete a single record from a MySQL table. The error I speak of is " 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 'LIMIT 1' at line 1 " The table I put together is called test ; it has 3 columns, id , name and created . I populated the table with several records and then attempted to delete one. Below is the statement I used to try and accomplish this. DELETE t FROM test t WHERE t.name = 'foo'