sql-delete

How to delete a row in mysql?

好久不见. 提交于 2019-12-25 14:08:40
问题 Is it possible to delete one or more rows from a table in MySql ? I want to delete the last two rows from the following table. +-------+--------------+-----------+--------------------+---------------+ | gp_no | no_of_member | amount | current_instalment | starting_date | +-------+--------------+-----------+--------------------+---------------+ | 1 | 15 | 375000.00 | 2 | 2015-05-01 | | 2 | 10 | 300000.00 | 1 | 2015-07-01 | | 3 | 15 | 450000.00 | 5 | 2015-04-01 | | 4 | 10 | 400000.00 | 0 | 2015

PostgreSQL: delete rows returned by subquery

∥☆過路亽.° 提交于 2019-12-25 09:00:21
问题 The basic syntax for DELETE is DELETE FROM table WHERE condition Is there a straightforward way to use subquery/alias in a DELETE statement, something like below? DELETE FROM (subquery) as sub WHERE condition Below is a minimal working table and my failed attempt to use subquery/alias: ---create table create table orderT ( id integer PRIMARY KEY, country_code varchar(2), created_date date, closed_date date); ---populate table INSERT INTO orderT VALUES (1, 'US', now(), now() + interval '1 day'

Delete join from two tables

隐身守侯 提交于 2019-12-25 08:08:36
问题 I need to create a join that will delete the entries in two tables. The delete will happen in projects when the project_id in the table is equal to the one on the page of the php document. I need the link entries on project_course to also be deleted. This is the code I have currently. $deleteSQL = sprintf("DELETE FROM projects p INNER JOIN project_course pc WHERE p.Project_id=%s", GetSQLValueString($_GET['Project_id'], "int")); Anybody know how to do this? I haven't done a join to delete

Delete MySQL information in table using Cron jobs

跟風遠走 提交于 2019-12-25 07:59:24
问题 I am using cPanel, trying to use cron jobs to delete all data in a table, but when I went to cron jobs in cPanel, I got an error when I put in the following: DELETE FROM patron_joined WHERE uid < NOW() - INTERVAL 1 MINUTE I checked my email for completion of the cron job and received the following message: /bin/sh: -c: line 0: syntax error near unexpected token `(' /bin/sh: -c: line 0: `DELETE FROM patron_joined WHERE uid < NOW() - INTERVAL 1 MINUTE' I have been researching this issue for the

How do I delete row with primary key using foreign key from other table?

好久不见. 提交于 2019-12-25 07:22:35
问题 I have a table called 'agenda' //translation: dairy with the following rows: idagenda // primary key title waar organisatie ... etc. ... I also have a table for the date of an diary item/event called agendadatum with the following rows: id // primary key idagenda // id from other table van //from tot // till datum // date When the field 'tot' is the date from Today it will delete the rows from the database, but the rows in the 'agenda' table remain untouched. They're not deleted, because I

SQL DELETE statement syntax

北城余情 提交于 2019-12-25 05:06:40
问题 Trying to execute a delete query and getting the following error Syntax error (missing operator) in query expression 'cname VALUES @cname'. code Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Settings.strFileName) conn.Open() Dim cmdText = "DELETE FROM products WHERE cname VALUES @cname" Dim cmd As OleDbCommand = New OleDbCommand(cmdText, conn) With cmd.Parameters .Add(New OleDbParameter("@cname", DataGridView1.Item("cname", i).Value))

MySQL 8 - Remove All Stored Procedures in a Specific Database

强颜欢笑 提交于 2019-12-25 03:35:10
问题 In MySQL 8 the database table `mysql`.`proc` does not exist. Previously I used this table to delete/remove/clear all stored procedures and recreate them from the source versioned code. This works very well to make sure development stored procedures where saved to source versioning before going to production. In MySQL versions before 8, this SQL query worked. DELETE FROM `mysql`.`proc` WHERE `type` = 'PROCEDURE' AND `db` = 'test'; Is there an alternate way to achieve the results of the query

Keep first of duplicate records and delete the rest

别说谁变了你拦得住时间么 提交于 2019-12-25 00:38:15
问题 This question does pretty much what I want to accomplish, but my table is more complicated and does not have a primary key. I also don't quite understand the top answer, what the t1 and t2 mean. If this answer can be applicable to me, would appreciate if someone explain the code. I have several months' tables that contain info on clients and the policies they hold. Every client has a unique policy ID, but they can have multiple policies, resulting in multiple records under the same policy ID.

In Oracle SQL, why are the deleted (uncommitted) rows not visible in current session but visible in other sessions?

做~自己de王妃 提交于 2019-12-24 11:28:45
问题 When a DELETE query is executed, from where exactly is the data deleted? Why is the data still visible in other sessions? What are the background processes that are carried out when a DELETE query is fired in Oracle SQL (at architecture level)? 回答1: As well as the discussion of ACID properties to which ziesemer referred you, you should know about Multi-Version Concurrency Control or MVCC. If you want to know 'all about it', consider reading Concurrency Control and Recovery in Database Systems

Multiple-table DELETE LIMIT

房东的猫 提交于 2019-12-24 10:37:33
问题 I'm trying to run following query but it throws an error. DELETE b FROM parim_lang a JOIN parim_lang b ON b.lang_hash = a.lang_hash AND b.lang_language = SUBSTRING(a.lang_google_translation, LOCATE('-', a.lang_google_translation) + 1) WHERE a.lang_google_translation REGEXP '^[a-z]+-[a-z]+' LIMIT 20 Without limit this query works.. Error looks like this: SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax