One way is to add index when creating the table
CREATE TABLE IF NOT EXISTS note (
id int AUTO_INCREMENT,
note_id int,
title varchar(50),
description varchar(50),
PRIMARY KEY(id),
INDEX ind_note_id (note_id)
);
Creates the same INDEX
ind_note_id
for
note_id
field on
note
table using
ALTER TABLE
CREATE TABLE IF NOT EXISTS note (
id int AUTO_INCREMENT,
note_id int,
title varchar(50),
description varchar(50),
PRIMARY KEY(id)
);
ALTER TABLE note
ADD INDEX ind_note_id (note_id);
Creates the same INDEX using
CREATE INDEX
statement
CREATE TABLE IF NOT EXISTS note (
id int AUTO_INCREMENT,
note_id int,
title varchar(50),
description varchar(50),
PRIMARY KEY(id)
);
CREATE INDEX ind_note_id ON note (note_id);