Hi to all,
I have 2 tables which are named "items" and "categories". Their structure is this:
items table:
item_id int not null auto_number primary key
item_name varchar(50)
item_description varchar(30)
item_category int not null
categories table:
cat_id int not null auto_number primary key
cat_name varchar(30)
If I issue a join query on those 2 tables, like this one:
SELECT
item_id,
item_name,
item_cost,
item_unit,
cat_name
FROM items
INNER JOIN categories
ON items.item_category = categories.cat_id;
Since this query is used a lot, which field do I need to create an INDEX with? Is it the item_category field in the "items" table?
Does a field have an INDEX automatically if it is a primary key field?
How about UNIQUE fields?
thanks and god bless.