[eluser]Unknown[/eluser]
Hello everyone,
I just have a quick question regarding Key usage in MySQL.
In the documentation under the "News" tutorial it tells us to create the following:
Code:
CREATE TABLE news (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(128) NOT NULL,
slug varchar(128) NOT NULL,
text text NOT NULL,
PRIMARY KEY (id),
KEY slug (slug)
);
My question is, why is it necessary to create
"KEY slug (slug)"?
Why not just retrieve the slug by the slug content in the column name?
For example "SELECT * FROM news WHERE slug = '$slug'"
In other words, I am curious to know the need for making slug a "KEY" in the MySQL table.
I am somewhat of a newbie, any response is appreciated.