sql-delete

Delete row with PHP - PDO on webpage

ぃ、小莉子 提交于 2019-12-13 01:23:05
问题 I am trying to delete a row from a table using PHP (PDO) on a page listing the rows entered into the database. I've been tinkering with the delete.php code to try to make it work but to no avail. I appreciate any help. Below is my code: listview.php session_start(); include_once('../includes/connection.php'); include_once('../includes/events.php'); $event = new Event; $events =$event->fetch_all(); if(isset($_SESSION['logged_in'])) { //display index ?> <html> <head> <meta charset="utf-8">

Got mired in a selective DELETE statement on a single table in t-SQL

耗尽温柔 提交于 2019-12-12 19:57:23
问题 Say, I have a table like this (SQL Server 2008): CREATE TABLE tbl (ID INT, dtIn DATETIME2, dtOut DATETIME2, Type INT) INSERT tbl VALUES (1, '05:00', '6:00', 1), -- will be removed (2, '05:00', '7:00', 1), -- will be removed (3, '05:01', '8:00', 1), (4, '05:00', '8:00', 1), (5, '05:00', '6:00', 2), -- will be removed (6, '05:00', '7:00', 2), (7, '05:00', '7:00', 3), (8, '04:00', '7:00', 3) I need to remove all records of the same 'type' (if 2 or more are found) with the same 'dtIn' for their

Deleting from two h2 tables with a foreign key

我与影子孤独终老i 提交于 2019-12-12 18:54:04
问题 I have an h2 database with two tables with foreign keys like CREATE TABLE master (masterId INT PRIMARY KEY, slaveId INT); CREATE TABLE slave (slaveId INT PRIMARY KEY, something INT, CONSTRAINT fk FOREIGN KEY (slaveId) REFERENCES master(slaveId)); and need something like DELETE master, slave FROM master m JOIN slave s ON m.slaveId = s.slaveId WHERE something = 43; i.e., delete from both tables (which AFAIK works in MySql). Because of the FOREIGN KEY I can't delete from the master first. When I

PHP DELETE immediately after select

若如初见. 提交于 2019-12-12 16:26:03
问题 I have a PHP server script that SELECTs some data from a MySQL database. As soon as I have the result from mysql_query and mysql_fetch_assoc stored in my own local variables, I want to delete the row I just selected. The problem with this approach is that it seems that PHP has done pass-by-reference to my local variables instead of pass-by-value, and my local variables become undefined after the delete command. Is there anyway to get around this? Here is my code: $query="SELECT id, peerID,

Is there a MySQL command drop all indexes except PRIMARY index?

为君一笑 提交于 2019-12-12 14:49:01
问题 I have a database table with one Index where the keyname is PRIMARY, Type is BTREE, Unique is YES, Packed is NO, Column is ID, Cardinality is 728, and Collation is A. I have a script that runs on page load that adds entries to the MySQL database table and also removes duplicates from the Database Table. Below is the script section that deletes the duplicates: // Removes Duplicates from the MySQL Database Table // Removes Duplicates from the MySQL Database Table based on 'Entry_Date' field

Two tables - how to delete rows if ID not referenced in both tables

杀马特。学长 韩版系。学妹 提交于 2019-12-12 14:27:56
问题 I have two tables: listings(item_id, ...) images(item_id, ...) The item_id value is the same in both tables - but I goofed and deleted listings from the 'listings' table without also deleting the corresponding row in the 'images' table. So - I want to delete all rows in the second 'images' table if item_id in IMAGES doesn't correspond to any of the more up-to-date item_id values in my primary 'listings' table. How do you delete all records in the 'images' table that are not referenced from

Delete rows with duplicates on two fields

非 Y 不嫁゛ 提交于 2019-12-12 04:44:06
问题 I need to delete duplicated values of this table: +----+-------+-------------+---------+ | id | name | description | surname | +----+-------+-------------+---------+ | 1 | Peter | Member | Hitsh | | 2 | James | Member | Tach | | 3 | Mary | Member | Popims | | 4 | Peter | Member | Hitsh | +----+-------+-------------+---------+ I would want to remove all the duplicated values with the same name and surname . 回答1: To keep the row with the smallest id for every set of duplicates on (name, surname

Dynamic delete in Oracle

徘徊边缘 提交于 2019-12-12 04:22:45
问题 I have Some static data for that i am creating select statement with the help of union all and i am comparing those data with DB table (departments).. with the help of minus i will get extra records which are in DB table and i need to delete those record......Need to sync up existing records with static data i hope this will clear the requirement.. Trying to delete a resultSet of select query in below query i am not sure where is my mistake.. getting SQL Error: ORA-01732: data manipulation

how to delete the latest some records in --safe-updates mode

孤街醉人 提交于 2019-12-12 03:44:12
问题 e.g. I want to delete the latest three records in below table root@localhost:[test]10:14:02>select * from delete_test order by create_time desc; +----+------+---------------------+ | id | code | create_time | +----+------+---------------------+ | 9 | fff | 2016-06-18 10:08:28 | | 8 | eee | 2016-06-18 10:08:21 | | 7 | ddd | 2016-06-18 10:08:15 | | 3 | ccc | 2016-06-17 22:18:48 | | 2 | bbb | 2016-06-17 22:18:42 | | 1 | aaa | 2016-06-17 22:18:37 | +----+------+---------------------+ first I

Delete where not in query

為{幸葍}努か 提交于 2019-12-12 03:29:30
问题 I have a lookup table ( ##lookup ). I know it's bad design because I'm duplicating data, but it speeds up my queries tremendously. I have a query that populates this table insert into ##lookup select distinct col1,col2,... from table1...join...etc... I would like to simulate this behavior: delete from ##lookup insert into ##lookup select distinct col1,col2,... from table1...join...etc... This would clearly update the table correctly. But this is a lot of inserting and deleting. It messes with