MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 4th, 2000, 02:21 PM
asktan asktan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 13 asktan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here I have a question,
can one table consists of 2 primary key ? thank you.

Reply With Quote
  #2  
Old May 5th, 2000, 01:16 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
You can't have two primary keys in a single table.

Only one primary key is allowded in a single table.



------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #3  
Old May 5th, 2000, 02:54 AM
asktan asktan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 13 asktan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i know one table can have 2 index keys but can't have 2 primary key. But in mysql how to add index key.

for example:
State lookup table:
(3 fields:country_id,state_id,statedesc)
data:

record 1('sg','st1','Happy State')
record 1('sg','st2','Perfect State')
record 1('sg','st3','Hello State')
record 1('tw','st1','Apple State')
record 1('tw','st2','Orange State')
record 1('tw','st3','Star State')
record 1('tw','st4','Bird State')

I want to set country_id and state_id as index key. how to do ? thank you.

Reply With Quote
  #4  
Old May 5th, 2000, 06:36 AM
WuzWuz WuzWuz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: Heerlen, The Netherlands
Posts: 24 WuzWuz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to WuzWuz
You can have a primary key consisting of two (or more) columns though. Have a look at http://www.mysql.com/Manual_chapter...ml#CREATE_TABLE

Hope this helps!

Greetz,
Peter



[This message has been edited by WuzWuz (edited May 05, 2000).]

Reply With Quote
  #5  
Old May 5th, 2000, 08:33 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Make a composite primary key when you create the table.

> create table state_lookup(
> country_id varchar(10) not null,
> state_id varchar(10) not null,
> statedesc varchar(50),
> primary key(country_id, state_id));

Reply With Quote
  #6  
Old May 8th, 2000, 01:51 PM
asktan asktan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 13 asktan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your helps

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > two primary key in one table

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap