MySQL Deleting Rows with DELETE Statement

Sample Deleting Rows with DELETE:

/* Real command */
DELETE FROM Professor WHERE ProfessorID > 2;

Using DELETE LOW_PRIORITY command:

mysql> DELETE LOW_PRIORITY FROM Orders
-> WHERE BookID=103
-> ORDER BY DateOrdered DESC
-> LIMIT 1;
Query OK, 1 row affected (0.03 sec)

Delete by JOIN:

mysql> DELETE Orders.*
-> FROM Books, Orders
-> WHERE Books.BookID=Orders.BookID
->    AND Books.BookName='News';
Query OK, 3 rows affected (0.05 sec)

Delete with JOIN 2:

DELETE FROM Orders
USING Books, Orders
WHERE Books.BookID=Orders.BookID
AND Books.BookName='Poet';

Using the ‘from join delete’ Alternative to Delete Data:

DELETE DVDs
FROM DVDs, Studios
WHERE DVDs.StudID=Studios.StudID
AND Studios.StudDescrip='New Line Cinema';

Delete row with condition:

DELETE from employee
WHERE id = 10;

About onlinejt

Blogger

,

No comments yet.

Leave a Reply

*