Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 19th, 2005, 12:21 PM   #1
darkone916
Hobbyist Programmer
 
darkone916's Avatar
 
Join Date: Jul 2005
Location: Oman
Posts: 125
Rep Power: 3 darkone916 is on a distinguished road
Send a message via MSN to darkone916
primary key

ahm... i have been learning MySQL lately 'cause i want to use them in webpages with php.
but there is just one simple thing that i couldn't figure how to do it:

How do you set a primary key in one of the fields?

Thank You!
__________________
From the bottom of the stone steps...
...i'm calling still.
darkone916 is offline   Reply With Quote
Old Nov 19th, 2005, 1:06 PM   #2
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
It's been a while since i did sql but i believe that if you set a field to "not null" and "unique" it becomes a primary key.
CREATE TABLE mytbl(custname CHAR(20) NOT NULL UNIQUE);
OpenLoop is offline   Reply With Quote
Old Nov 19th, 2005, 1:15 PM   #3
darkone916
Hobbyist Programmer
 
darkone916's Avatar
 
Join Date: Jul 2005
Location: Oman
Posts: 125
Rep Power: 3 darkone916 is on a distinguished road
Send a message via MSN to darkone916
Thanks A lot! And please don't think that i was just been lazy, i did do some googling and searching in the forum...
__________________
From the bottom of the stone steps...
...i'm calling still.
darkone916 is offline   Reply With Quote
Old Nov 19th, 2005, 2:14 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
CREATE TABLE mytbl
(
custname CHAR(20) NOT NULL,
...
...
...
PRIMARY KEY (custname),
...
...
);
is an alternative I use.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC