Re: update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



INSERT ... SELECT is for inserting values from another table into the
current one.  That is a different circumstance than what was described
in the original inquiry.

http://www.mysql.com/doc/en/INSERT.html


On Tue, 4 Feb 2003 14:32:45 +0100, Ignatius Reilly wrote:

>If you want to use WHERE clause, see the
>
>INSERT table
>SELECT ...
>
>syntax.
>
>Extremely convenient. You inherit all the flexibility of the SELECT
>statement.
>
>Ignatius
>____________________________________________
>----- Original Message -----
>From: "Doug Thompson" <dthompson@brickbarn.com>
>To: "Ike Austin" <iaustin@concentric.net>; <php-db@lists.php.net>
>Sent: Tuesday, February 04, 2003 2:17 PM
>Subject: Re:  update
>
>
>> UPDATE is for changing values in existing rows.  It appears you want to
>> add new information.  Use INSERT.
>>
>> $query= "INSERT tablename SET (username, email, location) VALUES(
>> $username, $email, $location)";
>> Note that a WHERE condition is incorrect for INSERT.
>>
>> Your UPDATE syntax is not correct either.  Note that you need only one
>> query to update any or all of the columns in a row.
>>
>> Using your example:
>>
>> $query="UPDATE tablename SET username=$username, email=$email,
>> location=$location WHERE userID=$id";
>>
>> Finally, your "Flash of Success" is not useful because it will print
>> even when the query fails.
>>
>> Doug
>>
>> On Thu, 30 Jan 2003 13:34:41 -0500, Ike Austin wrote:
>>
>> >Hello, Newbie question.
>> >
>> >And can the same SQL portion of the code be written something like...
>> >query= "UPDATE taablename SET (username, email, location)
>> >VALUEs( $username, $email, $location)";
>> >
>> >Any reason why this Update command would not execute?
>> >
>> >// BUILD AND EXECUTE QUERY TO SAVE USER INFO INTO DATABASE TABLE
>> >query = "UPDATE forumUsers SET username = '$name' WHERE userID = '$id'";
>> >result = @mysql_query($query);
>> >query2 = "UPDATE forumUsers SET email = '$emai' WHERE userID = '$id'";
>> >result2 = @mysql_query($query2);
>> >query3 = "UPDATE forumUsers SET Location = '$loc' WHERE userID = '$id'";
>> >result3 = @mysql_query($query3);
>> >
>> >/ INFORM FLASH OF SUCCESS
>> >print "&/:result=Updated Thanks";
>> >// CLOSE LINK TO DATABASE SERVER
>> >ysql_close($link);
>> >?>
>> >
>> >
>> >Ike
>>
>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>-- 
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux