sql-delete

%d format a number is required not str

时光毁灭记忆、已成空白 提交于 2019-12-08 11:15:40
问题 I have a table named tablename with idno as primary kry. I want the row to be deleted if the user specifies the idno in the table. Here are my codes: data3=raw_input("Enter the idno to del :",) mydata=cursor.execute("DELETE FROM tablename where idno=%d", data3) db.commit() I'm getting this error: Traceback (most recent call last): File "C:\Python27\trertr.py", line 50, in mydata=cursor.execute("DELETE FROM tablename where idno=%d", data3) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py

Can a row be deleted by specifying ROWNUM in Oracle 11g?

こ雲淡風輕ζ 提交于 2019-12-08 11:01:59
问题 I have some values as below: MYSTRING -------- Dharshan Ramalingam Devid I can select the specific row value through below query select * from ( select mystring , rownum rn FROM teststring ) where rn = 2; tell the way to delete this second row giving the row no and give me the brief explanation . I have tried as below but its not work.... delete from testring where rownum=2; 回答1: select * from ( select mystring , rownum rn FROM teststring ) where rn = 2; Your query returns rows randomly

Deleting a item from multilevel category or menu list

时间秒杀一切 提交于 2019-12-08 10:36:17
问题 I am making Categories system management like WordPress. As you can see in my database if i delete (or updating delete to 1) a category. All its child disappear fro the list. Before delete -> After delete -> But this not happening in the WordPress case. It deletes the selected category and assign its child to the parent of deleted category. I want to do the same. Step 1 -> get the parent of category which will be deleted. Step 2 -> update parent field of all child's of selected category with

UPDATE or DELETE first then INSERT

我是研究僧i 提交于 2019-12-08 07:27:07
问题 I'm asking this again, because I can't get a straight answer from other questions on SO. My situation is as follows, two tables, phones and features . Structure: phones id brand_id model picture published features id phone_id feature Now, features contains a whole lot of values, which only between 1 & 4 will correspond to a certain phone via phone_id . Now, when I update features, do you think deleting and then inserting new features again or updating existing features will be best? // edit:

Mass delete unpopular Tags

坚强是说给别人听的谎言 提交于 2019-12-08 05:15:47
问题 Mass delete unpopular Tags I have 1000's of tags and I would like to simply delete all tags that aren't used more than X times... i.e. 5 times. Does anyone know of a simple way to do this? Even straight SQL would totally ROCK! 回答1: $x = 5; // set this to any number $sql = "SELECT `name` FROM `wp_terms`"; $result = mysql_query($sql); $count = array(); while($row = mysql_fetch_assoc($result)) { $count[$name]++; } foreach($count as $key = $value) { if($value < $x) { $sql2 = "DELETE FROM `wp

SQL Duplicate Delete Query over Millions of Rows for Performance

邮差的信 提交于 2019-12-08 00:53:49
问题 This has been an adventure. I started with the looping duplicate query located in my previous question, but each loop would go over all 17 million records , meaning it would take weeks (just running *select count * from MyTable* takes my server 4:30 minutes using MSSQL 2005). I gleamed information from this site and at this post. And have arrived at the query below. The question is, is this the correct type of query to run on 17 million records for any type of performance? If it isn't, what

MySQL Trigger - delete after update

﹥>﹥吖頭↗ 提交于 2019-12-07 19:23:05
问题 For test case in one project I must delete record if one of fields meets one of conditions. Easiest seems be simple trigger: delimiter $$ drop trigger w_leb_go $$ create trigger w_leb_go after update on test for each row begin set @stat=NEW.res; set @id=NEW.id; IF @stat=3 THEN delete from test where id=@id; END IF; end$$ delimiter ; But as I suspect got error: update test set res=3 where id=1; ERROR 1442 (HY000): Can't update table 'test' in stored function/trigger because it is already used

delete duplicate entries in table [duplicate]

社会主义新天地 提交于 2019-12-07 14:13:35
问题 This question already has answers here : How to delete Duplicates in MySQL table (4 answers) Closed 6 years ago . I want to delete multiple duplicate keys from the below table: id | name | uid 1 | ekta | 5 2 | ekta | 5 3 | sharma | 10 4 | sharma | 10 want it to be like id | name | uid 1 | ekta | 5 3 | sharma | 10 I am using mysql. Is it ossible.? I can't use unique constraint query to make unique enteries because i want this duplicate entries ones entered to the table. 回答1: One way of doing

How to delete all records created today?

若如初见. 提交于 2019-12-07 12:12:29
问题 I am dealing with a very big database ~ 6 Million records. I've added ~30,000 bad records today. How can I delete all of the records created today in MySQL? 回答1: It seems created_at is a datetime. Try: delete from table where date(created_at) = curdate() Of course, run a select * prior to run this query and make sure the data you're going to delete is the one you really want to delete. 回答2: DELETE FROM Table WHERE ( (DAY(CallDate) = DAY(GETDATE()) AND (MONTH(CallDate) = MONTH(GETDATE()) AND

Multiple LEFT JOIN in Access

▼魔方 西西 提交于 2019-12-07 08:02:27
问题 I have the following query, which works for MySQL: DELETE `test1`, `test2`, `test3`, `test4` FROM `test1` LEFT JOIN `test2` ON test2.qid = test1.id LEFT JOIN test3 ON test3.tid = test2.id LEFT JOIN test4.qid = test1.id WHERE test1.id = {0} But it doesn't work for MS Access. I've tried to add parentheses around the LEFT JOIN , but it gives me syntax error in FROM clause. So how should this query look in order to work in MS Access? 回答1: The Access DELETE requires a star (*): DELETE * FROM ...