Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

How to create index in two table mysql?

0

90 views

please help me how to create index between two tables in mysql? I have "account" and "group" table. i have to index with "group_id with index_id)" and to be unique.

asked January 13, 2011 10:44 am CST
posted via StackOverflow

3 Answers

0
 

MySQL table indexes are on single tables.

Perhaps you're thinking of a FOREIGN KEY, which is only available with the InnoDB storage engine.

answered January 13, 2011 11:23 am CST
0
 

I just learned this myself, here, but apparently if you create a Unique constraint on a field, mySql will automatically create a nonclustered index on that field.

answered January 13, 2011 11:23 am CST
0
 

I think you're looking for a Foreign key.

This statement assumes that 'group_id' is a column in the account table and 'index_id' is a column in the group table.

ALTER TABLE account ADD CONSTRAINT group_index FOREIGN KEY (group_id) REFERENCES  group (index_id)

answered January 13, 2011 11:23 am CST

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions