Re: Primary Key question
so if I do want 'name' to be unique I must not make it primary, just simply unique, since my primary key is for id and name simultaneously. [EMAIL PROTECTED] wrote: your primary key is based on your (auto-increment) id and the name, PRIMARY KEY (`id`,`name`) so your two entries would be: 1,winxp 2,winxp there's no key conflict/duplication there. by the way, you do realize what the max range is on the (signed) tinyint (for your "id"), correct? Original Message Date: Friday, July 01, 2005 10:04:01 AM -0400 From: "Haisam K. Ido" <[EMAIL PROTECTED]> To: mysql@lists.mysql.com Subject: Primary Key question I've created the following table (server 4.1 in win2k) CREATE TABLE `os` ( `id` tinyint(10) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '', `description` varchar(255) default NULL, PRIMARY KEY (`id`,`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; and was very surprised that I can do the following twice. Should'nt this be rejected since name is a primary key ad has already been used? INSERT INTO os (name,description) VALUES ( 'winxp','winxp'); -- -- End Original Message -- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Primary Key question
"Haisam K. Ido" <[EMAIL PROTECTED]> wrote on 01/07/2005 15:04:01: > > I've created the following table (server 4.1 in win2k) > > CREATE TABLE `os` ( >`id` tinyint(10) NOT NULL auto_increment, >`name` varchar(255) NOT NULL default '', >`description` varchar(255) default NULL, >PRIMARY KEY (`id`,`name`) > ) ENGINE=MyISAM DEFAULT CHARSET=utf8; > > and was very surprised that I can do the following twice. Should'nt > this be rejected since name is a primary key ad has already been used? > > INSERT INTO os (name,description) VALUES ( 'winxp','winxp'); No. What you have requested is that the combination of id AND name be unique. Since id is auto-increment, every record will be unique unless you manually force the id to an old value. I guess you want the values to be separately unique, in which case you want PRIMARY KEY (id), UNIQUE (name) Alec -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Primary Key question
I've created the following table (server 4.1 in win2k) CREATE TABLE `os` ( `id` tinyint(10) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '', `description` varchar(255) default NULL, PRIMARY KEY (`id`,`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; and was very surprised that I can do the following twice. Should'nt this be rejected since name is a primary key ad has already been used? INSERT INTO os (name,description) VALUES ( 'winxp','winxp'); -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Primary Key Question
Hendro, In SQL an empty string is not null. PB Hendro Suryawan wrote: Hi all, I have table with primary key on field PO,BrgId, NOSP but when i try insert several new reccord with field NOSP = '', mysql will accept the new reccord without complaint error. Is this normal behavior? My perception if i have primary key on the three field the three field must be not empty. I try to alter the field NOSP with syntax : Alter table BrgIn2 Change NOSP NOSP Varchar(20) NOT NULL but if i looked table definition mysql always add default '' in the definition. How to tell mysql not to add default '', i want to this field always not null or ''. I use mysql 4.1.11 on FC3 X86_64. Can anyone help? Thanks in advance. regards, Hendro Table Create Table -- BrgIn2 CREATE TABLE `BrgIn2` ( `PO` varchar(17) NOT NULL default '', `BrgId` int(4) NOT NULL default '0', `NoSP` varchar(20) NOT NULL default '', `Spesifikasi` varchar(100) default NULL, `Qty` decimal(10,3) NOT NULL default '0.000', `Price` decimal(19,4) NOT NULL default '0.', `Disc` decimal(6,4) default NULL, `DPP` decimal(10,4) default NULL, `Tax` decimal(6,4) default '0.', `pph` decimal(6,4) default '0.', `Kurs` decimal(10,4) default NULL, `ShipDate` date default NULL, `Currcy` varchar(10) NOT NULL default '', `Keterangan` blob, `Terima` decimal(9,2) default NULL, `Periode` varchar(7) default NULL, `TglInput` date default NULL, `Operators` varchar(50) default NULL, `Workstation` varchar(30) default NULL, PRIMARY KEY (`PO`,`BrgId`,`NoSP`), KEY `BrgIn2SPBrg` (`NoSP`,`BrgId`,`Qty`), KEY `BrgId` (`BrgId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.7.6/19 - Release Date: 6/16/2005 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Primary Key Question
Hendro Suryawan <[EMAIL PROTECTED]> wrote on 06/16/2005 06:53:31 PM: > Hi all, > I have table with primary key on field PO,BrgId, NOSP but when i try > insert several new reccord with field NOSP = '', mysql will accept the > new reccord without complaint error. > Is this normal behavior? As long as the combination of the values {PO, BrgId, NoSP} does not yet exist on the table, you should be able to add rows. Are you saying that, for example, that the combination {'somePOvalue', 4, ''} already exists on your table and it's allowing you to add a second row with the same combination of values? > My perception if i have primary key on the > three field the three field must be not empty. I try to alter the field > NOSP with syntax : > Alter table BrgIn2 Change NOSP NOSP Varchar(20) NOT NULL > but if i looked table definition mysql always add default '' in the > definition. How to tell mysql not to add default '', i want to this > field always not null or ''. I use mysql 4.1.11 on FC3 X86_64. > Can anyone help? Thanks in advance. > regards, > Hendro > Table Create Table > -- > BrgIn2 CREATE TABLE `BrgIn2` ( > `PO` varchar(17) NOT NULL default '', > `BrgId` int(4) NOT NULL default '0', > `NoSP` varchar(20) NOT NULL default '', > PRIMARY KEY (`PO`,`BrgId`,`NoSP`), > KEY `BrgIn2SPBrg` (`NoSP`,`BrgId`,`Qty`), > KEY `BrgId` (`BrgId`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 The empty string ('') is not a NULL value. It represents a string that contains no characters. A NULL value indicates the lack of information, a state of non-existence. For instance: Imagine you have a table, Person, and the table has fields to hold a first name, a middle name, and a last name. If you know for a fact that some person does not have a middle name, you would use a '' (empty string) for the MiddleName value of that person. However, if you don't have a middle name on a data entry form for a particular person (a middle name may exist but you didn't get it as part of your data), you would use a NULL value to indicate the absence of information. I think what you would like to have is a CHECK constraint on the `NoSP` field that requires that all new or updated values have a certain minimum length (LENGTH(`NoSP`) > 0). However, MySQL does not yet support CHECK constraints (see the TODO lists). Until it does, you will need to enforce that particular restriction using your application code (any version) or write that check into a TRIGGER (v5.0+). Shawn Green Database Administrator Unimin Corporation - Spruce Pine
Primary Key Question
Hi all, I have table with primary key on field PO,BrgId, NOSP but when i try insert several new reccord with field NOSP = '', mysql will accept the new reccord without complaint error. Is this normal behavior? My perception if i have primary key on the three field the three field must be not empty. I try to alter the field NOSP with syntax : Alter table BrgIn2 Change NOSP NOSP Varchar(20) NOT NULL but if i looked table definition mysql always add default '' in the definition. How to tell mysql not to add default '', i want to this field always not null or ''. I use mysql 4.1.11 on FC3 X86_64. Can anyone help? Thanks in advance. regards, Hendro Table Create Table -- BrgIn2 CREATE TABLE `BrgIn2` ( `PO` varchar(17) NOT NULL default '', `BrgId` int(4) NOT NULL default '0', `NoSP` varchar(20) NOT NULL default '', `Spesifikasi` varchar(100) default NULL, `Qty` decimal(10,3) NOT NULL default '0.000', `Price` decimal(19,4) NOT NULL default '0.', `Disc` decimal(6,4) default NULL, `DPP` decimal(10,4) default NULL, `Tax` decimal(6,4) default '0.', `pph` decimal(6,4) default '0.', `Kurs` decimal(10,4) default NULL, `ShipDate` date default NULL, `Currcy` varchar(10) NOT NULL default '', `Keterangan` blob, `Terima` decimal(9,2) default NULL, `Periode` varchar(7) default NULL, `TglInput` date default NULL, `Operators` varchar(50) default NULL, `Workstation` varchar(30) default NULL, PRIMARY KEY (`PO`,`BrgId`,`NoSP`), KEY `BrgIn2SPBrg` (`NoSP`,`BrgId`,`Qty`), KEY `BrgId` (`BrgId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Compound Primary Key question
As Jeremy says - it depends totally on what you want to do. If you have tables where there is no logical, unique way to identify that column (or the only way to do so is via a column you do not want to use for this purpose), then assigning a separate ID column as a PK makes sense. E.g: If you have a lookup table 'ItemDescription' which contains a list of description fields for items, it would make sense to make the table (ItemID, Description) with ItemID being an autoincrement primary key. However, in some other cases, a compound key will make more sense - for instance if you have a 'glue table' such as 'Item_Shop' which lists the items that are available in each shop: (ItemID, ShopID), then clearly, you cannot have a PK on either column alone (since there is a many to many relationship), so a compound PK is the only way to actually put a PK on the table (and uniquely identify a given row). One rule of thumb is: If there are two or more columns within a given table which together are the logical way to identify that row (and the way you would always join to the table), then use those as a compound key, otherwise assign a separate autoincrement column as a PK. Cheers, Matt > -Original Message- > From: Jeremy Zawodny [mailto:[EMAIL PROTECTED] > Sent: 23 April 2004 23:51 > To: Emmett Bishop > Cc: [EMAIL PROTECTED] > Subject: Re: Compound Primary Key question > > On Fri, Apr 23, 2004 at 03:40:43PM -0700, Emmett Bishop wrote: > > Quick question. In general, is it better to create > > compound primary keys or use an auto increment field > > to uniquely identify each record? > > Yes. > > It depends on your application and your data. > > Jeremy > -- > Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo! > <[EMAIL PROTECTED]> | http://jeremy.zawodny.com/ > > [book] High Performance MySQL -- http://highperformancemysql.com/ > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Compound Primary Key question
On Fri, Apr 23, 2004 at 03:40:43PM -0700, Emmett Bishop wrote: > Quick question. In general, is it better to create > compound primary keys or use an auto increment field > to uniquely identify each record? Yes. It depends on your application and your data. Jeremy -- Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo! <[EMAIL PROTECTED]> | http://jeremy.zawodny.com/ [book] High Performance MySQL -- http://highperformancemysql.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Compound Primary Key question
Quick question. In general, is it better to create compound primary keys or use an auto increment field to uniquely identify each record? --T __ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25ยข http://photos.yahoo.com/ph/print_splash -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Primary key question
On Tue, 17 Dec 2002 19:15:08 +0100, Serrand Patrice wrote: >Does MySQL automatically create index on primary key ? Yes. See http://www.mysql.com/doc/en/CREATE_TABLE.html - Steve Yates - Antonym: The opposite of the word you're searching for. ~ Taglines by Taglinator - www.srtware.com ~ - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Primary key question
Hi, Does MySQL automatically create index on primary key ? If not how can I create an index on a primary key ? Thanks for any help. Patrice Serrand - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
re: Primary Key Question
On Monday 16 December 2002 18:12, tmb wrote: > I understood that MySQL didn't internally keep up with > the relationships between tables... like MS Access... > > And that it was up to the programmer to referential > integrity... > > But I noticed in phpMyAdmin that the offer the option > of defining a column in a table as 'Primary' > > Am I confused on this or is this something that > phpMyAdmin takes does ?? Yes, you can define column as a primary key. It uniquely references to a particular record in the table. So values must be unique and non-null. What exactly confused you? -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Primary Key Question
I understood that MySQL didn't internally keep up with the relationships between tables... like MS Access... And that it was up to the programmer to referential integrity... But I noticed in phpMyAdmin that the offer the option of defining a column in a table as 'Primary' Am I confused on this or is this something that phpMyAdmin takes does ?? thanks for any help. tmb __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: mysql primary key question!
if this interests you at all, i found this yesterday on the evolt.org mailing list. the gentleman who has put this very useful code basically suggested that i could "base36" my auto_increment IDs. i will leave this here for those of you who are intersted: http://www.faqts.com/knowledge_base/view.phtml/aid/17710 i use this in the same table. one of the ID fields is auto_incremented. when an ID is generated, i calculate the base36 of that number and put it into my other field which i have to use for my purposes. php or mysql should consider putting this code in their language itself, especially mysql because it can be used for alphanumeric sequences! i dont know if i am making sense, but my problem is solved. hope this helps someone! :) cheers/erick --- Carl McNamee <[EMAIL PROTECTED]> wrote: > Erick, > > We did that very thing here. Our staff wrote a Unique Record > Identifier > (URI) program that was called by the programs that actually put the > data > into the database. The generated URI was then used as the primary key. > However, I must say up front that this type of thing is fraught with > problems. Here are the ones we ran into that I'm aware of. > 1. Performance can stink. If you ask the URI generator for each > record > things are slow. We got around this somewhat by figuring out how many > records a program was working with and requresting a block of URI's. > So now > you have to modify your programs too! > 2. The URI generator must keep track of the URI's it hands out. So > you > need another database table, and its associated overhead, just to keep > track > of this. > 3. If the system crashes and the URI tables were not updated you could > start handing out duplicate URI's after the system recovers. How will > your > application handle this? The database will reject the records assuming > that > the URI is your primary key but how do you fix the URI database? > > If anyone responds with a better way it would be great if you'd post it > to > the mysql list. > > Carl McNamee > Systems Administrator > Billing Concepts > (210) 949-7282 > > -----Original Message- > From: Erick Papadakis [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 08, 2002 6:30 AM > To: mysql > Subject: mysql primary key question! > > > hello, > > i hope some database guru can help me with this! > > i need to set up an auto_increment field inside mysql. for various > reasons, the maximum size is 3. but i don't want this to be ONLY > integers > because that limits me until 999 numbers only. since i have all > flexibility for these three digits or letters, i want to include > numbers > and some characters into it as well. e.g., > > m78 > 23a > 1pt > 1~8 > !76 > > ...etc can all be valid keys for me. > > how can i generate such numbers on the fly? if not inside mysql, then > inside php? AND...be sure that the "key" so generated has not been used > before as an id field in my data? > > any ideas would be very welcome! > > thanks very much in advance/erick > __ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: mysql primary key question!
* Erick Papadakis > i need to set up an auto_increment field inside mysql. for various > reasons, the maximum size is 3. Could you say something about these reasons...? > but i don't want this to be ONLY integers > because that limits me until 999 numbers only. Well... using three _bytes_, the unsigned range for mediumint is 0 - 16777215. If you want to restrict the _visual_ width of the column to be three characters, then you are right, the limit for integers are 999. auto_increment works with integers only. > since i have all > flexibility for these three digits or letters, i want to include numbers > and some characters into it as well. e.g., > > m78 > 23a > 1pt > 1~8 > !76 > > ...etc can all be valid keys for me. > > how can i generate such numbers on the fly? if not inside mysql, then > inside php? I don't think you can do this in an efficient way inside mysql, but using PHP you should be able to calculate a number into a three character string. One way may be to use a base 36 integer... in python it would be something like this: >>> import string >>> def base36(x): ... d = string.digits+string.lowercase ... a = x/(36*36) ... b = (x-(a*36*36))/36 ... c = x-(a*36*36)-(b*36) ... return d[a]+d[b]+d[c] ... >>> base36() '7pr' >>> int('7pr',36) >>> The max value would be 46655: >>> base36(46655) 'zzz' You could use a SMALLINT (2 bytes only) and auto_increment, and convert the integer value to the base36() value before you display it on the screen. This would ensure max three characters in this column. -- Roger sql - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: mysql primary key question!
IMHO you can INCREMENT only numbers . :) . Why only three numbers ? Anyway i'd see a solution like this : table : idfield [1..n] Select (@max_number:=max(id)) from table; Insert into table(id,field1,fieldn) values (@max+0.1,'xxx','xxx'); that's kindof solution . - Original Message - From: "Erick Papadakis" <[EMAIL PROTECTED]> To: "mysql" <[EMAIL PROTECTED]> Sent: Monday, July 08, 2002 2:30 PM Subject: mysql primary key question! > hello, > > i hope some database guru can help me with this! > > i need to set up an auto_increment field inside mysql. for various > reasons, the maximum size is 3. but i don't want this to be ONLY integers > because that limits me until 999 numbers only. since i have all > flexibility for these three digits or letters, i want to include numbers > and some characters into it as well. e.g., > > m78 > 23a > 1pt > 1~8 > !76 > > ...etc can all be valid keys for me. > > how can i generate such numbers on the fly? if not inside mysql, then > inside php? AND...be sure that the "key" so generated has not been used > before as an id field in my data? > > any ideas would be very welcome! > > thanks very much in advance/erick > > > > __ > Do You Yahoo!? > Sign up for SBC Yahoo! Dial - First Month Free > http://sbc.yahoo.com > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: mysql primary key question!
Hi, My opinion: You can't use auto_increment in this way.For sure you must do some functions in php to check flexibility conditions of the digits which are using for new ID of entire row.The ID field from your table must be CHAR(). E.g: You need 3 variables; set @a:="";--initialize variable a; set @b:="";--initialize variable b; set @c:="";--initialize variable c; select @a:=some_peculiar_for_gen_the_id from your_table where your_conditions; select @b:=other_peculiar_for_gen_the_id from your_table where your_conditions; select @c:=other_peculiar_for_gen_the_id from your_table where your_conditions; insert into table_for_insert_data SET ID_FIELD=CONCAT(@a,@b,@c) and ...others data; Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: "Erick Papadakis" <[EMAIL PROTECTED]> To: "mysql" <[EMAIL PROTECTED]> Sent: Monday, July 08, 2002 2:30 PM Subject: mysql primary key question! > hello, > > i hope some database guru can help me with this! > > i need to set up an auto_increment field inside mysql. for various > reasons, the maximum size is 3. but i don't want this to be ONLY integers > because that limits me until 999 numbers only. since i have all > flexibility for these three digits or letters, i want to include numbers > and some characters into it as well. e.g., > > m78 > 23a > 1pt > 1~8 > !76 > > ...etc can all be valid keys for me. > > how can i generate such numbers on the fly? if not inside mysql, then > inside php? AND...be sure that the "key" so generated has not been used > before as an id field in my data? > > any ideas would be very welcome! > > thanks very much in advance/erick > > > > __ > Do You Yahoo!? > Sign up for SBC Yahoo! Dial - First Month Free > http://sbc.yahoo.com > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
mysql primary key question!
hello, i hope some database guru can help me with this! i need to set up an auto_increment field inside mysql. for various reasons, the maximum size is 3. but i don't want this to be ONLY integers because that limits me until 999 numbers only. since i have all flexibility for these three digits or letters, i want to include numbers and some characters into it as well. e.g., m78 23a 1pt 1~8 !76 ...etc can all be valid keys for me. how can i generate such numbers on the fly? if not inside mysql, then inside php? AND...be sure that the "key" so generated has not been used before as an id field in my data? any ideas would be very welcome! thanks very much in advance/erick __ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SQL PRIMARY KEY question
On Sat, Feb 17, 2001 at 12:07:53PM +0100, Cedric Lefebvre wrote: > I have written the following SQL request, but I get > an error, why ? > > create table MovementOrder ( > teamCode INT(4) NOT NULL, > quarter INT(4) NOT NULL, > position INT(4) NOT NULL, > priority INT(4) NOT NULL, > order VARCHAR(10), order is a reserved word which you can't use for any of your own names (i.e. field names, table names, index names or variable names). > parameter VARCHAR(5), > PRIMARY KEY(teamCode,quarter,position,priority) > ); > Your subject line seems to indicate a problem with PRIMARY KEY, but without more information it's hard to tell. Please be more elaborate on your next question. Usually you would mention the exact error message, the version of MySQL you're using, the OS you're running on, client software used (like PHP, Perl), etc. Fred. -- Fred van Engen XO Communications B.V. email: [EMAIL PROTECTED] Televisieweg 2 tel: +31 36 5462400 1322 AC Almere fax: +31 36 5462424 The Netherlands - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: SQL PRIMARY KEY question
Lyrics: I found it weird that people don't even realize that one must learn to learn and for that one must learn to ask questions. I also often find that people who cannot ask questions are either idiots beyond hope or very much egoists. That, of course, does not apply to every single case. There are exceptions (too much beer, too much work, too few hours of sleep, too much necotine or other drugs). However, those are bad excuse for a asking a bad question. Just consider this: when you're asking a question you are expecting other people to help you absolutelly for free to you, but it costs time money and health to the aswerring person, so why not to make that person's job easier by putting as much info as you can in your question? Now for the topic: WHAT ERROR ARE YOU GETTING? You probably used a reseved word for field name. Artem - Original Message - From: "Cedric Lefebvre" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, February 17, 2001 2:07 PM Subject: SQL PRIMARY KEY question > I have written the following SQL request, but I get > an error, why ? > > create table MovementOrder ( > teamCode INT(4) NOT NULL, > quarter INT(4) NOT NULL, > position INT(4) NOT NULL, > priority INT(4) NOT NULL, > order VARCHAR(10), > parameter VARCHAR(5), > PRIMARY KEY(teamCode,quarter,position,priority) > ); > > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
SQL PRIMARY KEY question
I have written the following SQL request, but I get an error, why ? create table MovementOrder ( teamCode INT(4) NOT NULL, quarter INT(4) NOT NULL, position INT(4) NOT NULL, priority INT(4) NOT NULL, order VARCHAR(10), parameter VARCHAR(5), PRIMARY KEY(teamCode,quarter,position,priority) ); - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php