Re: INSERT Question

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

 



You can't perform update like this.
You should loop through rows you want to update if they have different key
values.

UPDATE tbl_ib_articles SET col_name=new_value WHERE key_column=key_value;

You can change the condition part, which can include non-key columns,

HTH,
Mustafa



----- Original Message -----
From: "Charles Kline" <ckline@rightcode.net>
To: <JanetVal@aol.com>
Cc: <php-db@lists.php.net>
Sent: Tuesday, April 01, 2003 5:56 AM
Subject: Re:  INSERT Question


Everything looks okay with this when I echo the sql string:

INSERT INTO tbl_ib_articles (issue_brief,article) VALUES
('24','30'),('24','20'),('24','31')

My question was, what do I need to change to make this an UPDATE?

Thanks,
Charles

On Monday, March 31, 2003, at 08:30 PM, JanetVal@aol.com wrote:

> In a message dated 3/31/2003 5:26:36 PM Pacific Standard Time,
> ckline@rightcode.net writes:
>
>
> > then I built the INSERT like so:
> > foreach($article_keys as $articleid)
> > {
> > $insert[] = "('$v_ib_id','$articleid')";
> > }
> > $article_sql = "INSERT INTO tbl_ib_articles (issue_brief,article)
> > VALUES " . implode(',',$insert);
>
>
>
> It's pretty much okay, except you don't have ( ) around the string
> that you create with the implode. You can echo $article_sql to see
> exactly what the SQL looks like and you can then modify your statement
> so you get the right SQL.
>
> Janet


--
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