RE: [PHP] quicky sql question

From: Date: Thu, 21 Dec 2000 18:06:11 +0000
Subject: RE: [PHP] quicky sql question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31386@lists.php.net to get a copy of this message
Maxim Maletsky writes: > I have never read this part of the manual, but one thing I am sure in: > > INSERT INTO com_site (ACTIVE, TITLE) VALUES('1', 'test') > > will work for sure, > also (since it looks like UID is an autoincrement) you could make him be: > > INSERT INTO com_site (UID, ACTIVE, TITLE) VALUES(NULL, '1', 'test') > > this will also work, > > now why do you say that INSERT and SET can work together? > is that in manual? > can you give me the link? > > Cheers! I say it because I use it all the time. Why do you say it does not exist? It is in the manual, or I would not have quoted it from the manual. :) The link is here: http://www.mysql.com/documentation/mysql/commented/manual.php?section=INSERT Cheers, Torben > -----Original Message----- > From: Lars Torben Wilson [mailto:torben@pinc.com] > Sent: Thursday, December 21, 2000 9:47 PM > To: Marc Davenport > Cc: php-general@lists.php.net > Subject: Re: [PHP] quicky sql question > > > Marc Davenport writes: > > Here is a quick one someone can answer > > > > What is wrong with this SQL query > > > > INSERT INTO com_site SET (UID='' , ACTIVE='1' , > > TITLE='test') > > > > UID is NOT NULL, but it is set to AUTO_INCREMENT > > and I am using a version of mysql that accepts the SET structure. > > I've been looking at it a couple minutes, but I dont see the problem. > > Its probably really easy. > > > > Thanks in advance > > Marc > > >From the MySQL manual, the syntax for this is: > > INSERT [LOW_PRIORITY | DELAYED] [IGNORE] > [INTO] tbl_name > SET col_name=expression, col_name=expression, ... > > ...so you should be writing: > > INSERT INTO com_site SET active='1', title='test'; > > Don't set the auto_increment field to anything--it'll > be...er...incremented automatically ;)--and drop the parens and you > should be laughing. > > > Good luck, > > Torben > > -- > +----------------------------------------------------------------+ > |Torben Wilson <torben@php.net> Netmill iTech| > |http://www.coastnet.com/~torben > http://www.netmill.fi| > |Ph: 1 250 383-9735 torben@netmill.fi| > +----------------------------------------------------------------+ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.general (#31386) next »