Re: UPDATE (SELECT ) is not working................
Archana K N <[email protected]> Fri, 17 Jan 2014 14:46:37 +0530
| Newsgroups | gmane.comp.db.postgresql.php |
|---|---|
| Message-ID | <CACa6=i2VhUUj4gNeh7YwzzfwX6Kid2P7xH9y_Gx3_POXbKG61g@mail.gmail.com> |
--001a1136516cccf55904f026ff29
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Sorry it is not 'database' ,but 'table' . I followed the syntax given
*UPDATE table_name SET(columns) FROM (SELECT columns FROM table_2) AS
som-val WHERE condition;*
And I tried it in psql command line as
my_db=# update test set id=g.id2 from (select id2 from test2)as g ;
UPDATE 0
where my_db is the database I created.
regards
archana
On Fri, Jan 17, 2014 at 2:34 PM, Andrew McMillan <[email protected]>wrote:
> On Fri, 2014-01-17 at 13:58 +0530, Archana K N wrote:
> > Hello,
> >
> >
> > I am trying to update a database with values from another . Am
> > using Debain(Linux) OS.
> >
> >
> > When I try to update no error is displayed. But column is not
> > updated.
> > I am using the psql console for querying.
> >
> >
> > my code is as follows(along with result):-
> >
> >
> > ""my_db=# update test set id=g.id2 from (select id2 from test2)as g ;
> > UPDATE 0
>
> Your SQL does not do what you think it does.
>
> You should probably test your SQL at the psql command line to figure out
> the correct way to do what you want to do before you try and post to a
> PHP mailing list about this kind of thing.
>
> I'd offer advice, but I can't figure out from your statement what you're
> trying to do your database either.
>
> Cheers,
> Andrew.
>
>
> --
> ------------------------------------------------------------------------
> andrew (AT) morphoss (DOT) com +64 (2) 7233 2426
> IOT trap -- core dumped
> ------------------------------------------------------------------------
>
>
>
>
> --
> Sent via pgsql-php mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-php
>
--
-------------------
regards
archana
--------------------
--001a1136516cccf55904f026ff29
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<div><br></div><div>=A0 =A0 =A0Sorry =A0it is not '=
database' ,but 'table' . I followed the syntax given=A0</div><d=
iv><br></div><div><i>UPDATE table_name SET(columns) FROM (SELECT columns FR=
OM table_2) AS som-val WHERE condition;</i></div>
<div><i><br></i></div><div>And I tried it in psql command line as</div><div=
><br></div><div><span style=3D"color:rgb(80,0,80);font-family:arial,sans-se=
rif;font-size:13px">my_db=3D# update test set id=3Dg.id2 from (select id2 f=
rom test2)as g ;</span><br style=3D"color:rgb(80,0,80);font-family:arial,sa=
ns-serif;font-size:13px">
<span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13=
px">=A0UPDATE 0</span><br></div><div><span style=3D"color:rgb(80,0,80);font=
-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style=
=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">where m=
y_db is the database I created.</span></div>
<div><span style=3D"color:rgb(80,0,80);font-family:arial,sans-serif;font-si=
ze:13px"><br></span></div><div><span style=3D"color:rgb(80,0,80);font-famil=
y:arial,sans-serif;font-size:13px">regards</span></div><div><span style=3D"=
color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">archana</sp=
an></div>
</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Fri,=
Jan 17, 2014 at 2:34 PM, Andrew McMillan <span dir=3D"ltr"><<a href=3D"=
mailto:[email protected]" target=3D"_blank">[email protected]</a>></=
span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">On Fri, 2014-01-17 at 13:5=
8 +0530, Archana K N wrote:<br>
> Hello,<br>
><br>
><br>
> =A0 =A0 =A0I am trying to update a database with values from another .=
Am<br>
> using Debain(Linux) OS.<br>
><br>
><br>
> =A0 =A0 =A0 =A0 When I try to update no error is displayed. But column=
is not<br>
> updated.<br>
> I am using the psql console for querying.<br>
><br>
><br>
> my code is as follows(along with result):-<br>
><br>
><br>
> ""my_db=3D# update test set id=3Dg.id2 from (select id2 from=
test2)as g ;<br>
> UPDATE 0<br>
<br>
</div>Your SQL does not do what you think it does.<br>
<br>
You should probably test your SQL at the psql command line to figure out<br=
>
the correct way to do what you want to do before you try and post to a<br>
PHP mailing list about this kind of thing.<br>
<br>
I'd offer advice, but I can't figure out from your statement what y=
ou're<br>
trying to do your database either.<br>
<br>
Cheers,<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 Andrew.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
<br>
--<br>
------------------------------------------------------------------------<br=
>
andrew (AT) morphoss (DOT) com =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 <a href=3D"tel:%2B64%20%282%29%207233%202426" value=3D"+64272332426">+6=
4 (2) 7233 2426</a><br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 IOT trap -- core dumped<br>
------------------------------------------------------------------------<br=
>
<br>
<br>
<br>
<br>
--<br>
Sent via pgsql-php mailing list (<a href=3D"mailto:[email protected]=
">[email protected]</a>)<br>
To make changes to your subscription:<br>
<a href=3D"http://www.postgresql.org/mailpref/pgsql-php" target=3D"_blank">=
http://www.postgresql.org/mailpref/pgsql-php</a><br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r>-------------------<br>regards<br>archana<br>--------------------
</div>
--001a1136516cccf55904f026ff29--