Prev | Current Page 147 | Next

Emilian Balanescu and Cristian Darie

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

However, you??™re allowed to manually specify
a value, if you prefer.
?– Tip Because department_id is the primary key column, trying to add more records with the same ID
would cause the database to generate an error. The database doesn??™t permit having duplicate values in the
primary key field.
When letting MySQL generate values for AUTO_INCREMENT columns, you can obtain the last
generated value using the LAST_INSERT_ID() function. Here??™s an example of how this works:
INSERT INTO department (name) VALUES ('Some New Department');
SELECT LAST_INSERT_ID();
?– Tip In MySQL, the semicolon (;) is the delimiter between SQL commands.
CHAPTER 4 ?–  CREATING THE PRODUCT CATALOG: PART 1 81
UPDATE
The UPDATE statement is used to modify existing data and has the following syntax:
UPDATE
SET = [, = ... ]
[WHERE ]
The following query changes the name of the department with the ID of 43 to Cool
Department. If there were more departments with that ID, all of them would have been modified,
but because department_id is the primary key, you can??™t have more departments with the
same ID.
UPDATE department SET name='Cool Department' WHERE department_id = 43;
Be careful with the UPDATE statement, because it makes messing up an entire table easy.
If the WHERE clause is omitted, the change is applied to every record of the table, which you
usually don??™t want to happen.


Pages:
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
reklama internetowa teksty piosenek Poker Porady obrazki poker online