Re: quicky sql question
| From: | Lars Torben Wilson | Date: | Thu, 21 Dec 2000 12:47:07 +0000 |
| Subject: | Re: quicky sql question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31366@lists.php.net to get a copy of this message | ||
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|
+----------------------------------------------------------------+