Prev | Current Page 148 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

MySQL will be happy to change all of your records; even if all
departments in the table would have the same name and description, they would still be
perceived as different entities because they have different department_id values.
DELETE
The syntax of the DELETE command is actually very simple:
DELETE FROM
[WHERE ]
Most of the time, you??™ll want to use the WHERE clause to delete a single row:
DELETE FROM department WHERE department_id = 43;
As with UPDATE, be careful with this command, because if you forget to specify a WHERE
clause, you??™ll end up deleting all of the rows in the table. The table itself isn??™t deleted by the
DELETE command; for that purpose, you??™d use DROP TABLE ( http://dev.mysql.com/doc/refman/
5.0/en/drop-table.html).
The following query deletes all the records in department:
DELETE FROM department;
MySQL Stored Procedures
A stored procedure is a named set of SQL commands stored in the MySQL server. Similar to
functions in PHP, stored procedures can receive parameters and return data. Stored procedures
in MySQL 5.1 follow the ANSI SQL 2003 specification. Their official documentation page is
http://www.mysql.org/doc/refman/5.1/en/stored-procedures.html.
You don??™t need to use stored procedures if you want to perform database operations. You
can directly send SQL commands from an external application (such as a PHP script of your
TShirtShop application) to your MySQL database.


Pages:
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160