![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
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. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
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); |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
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. |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
CREATE TABLE mytbl ( custname CHAR(20) NOT NULL, ... ... ... PRIMARY KEY (custname), ... ... );
__________________
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|