pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
UPDATE (SELECT ) is not working................
4+ messages / 3 participants
[nested] [flat]

* UPDATE (SELECT ) is not working................
@ 2014-01-17 08:28  Archana K N <archanakknn@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Archana K N @ 2014-01-17 08:28 UTC (permalink / raw)
  To: pgsql-php

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

Thanks in advance............
-- 
-------------------
regards
archana
--------------------

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: UPDATE (SELECT ) is not working................
@ 2014-01-17 09:04  Andrew McMillan <andrew@morphoss.com>
  parent: Archana K N <archanakknn@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Andrew McMillan @ 2014-01-17 09:04 UTC (permalink / raw)
  To: pgsql-php

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 (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: UPDATE (SELECT ) is not working................
@ 2014-01-17 09:16  Archana K N <archanakknn@gmail.com>
  parent: Andrew McMillan <andrew@morphoss.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Archana K N @ 2014-01-17 09:16 UTC (permalink / raw)
  To: Andrew McMillan <andrew@morphoss.com>; +Cc: pgsql-php

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 <andrew@morphoss.com>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 (pgsql-php@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-php
>



-- 
-------------------
regards
archana
--------------------

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: UPDATE (SELECT ) is not working................
@ 2014-01-17 09:33  Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
  parent: Archana K N <archanakknn@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Mark Kirkwood @ 2014-01-17 09:33 UTC (permalink / raw)
  To: Archana K N <archanakknn@gmail.com>; pgsql-php

On 17/01/14 21:28, Archana K N wrote:

>
> ""*/my_db=# update test set id=g.id2 from (select id2 from test2)as g ;/*
> */UPDATE 0/*
> ""
>

'UPDATE 0' means 0 rows where found to update. So everything is working 
fine, but your query search criteria is finding no candidate rows to 
change. This is purely a data issue.

Regards

Mark



-- 
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2014-01-17 09:33 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-01-17 08:28 UPDATE (SELECT ) is not working................ Archana K N <archanakknn@gmail.com>
2014-01-17 09:04 ` Andrew McMillan <andrew@morphoss.com>
2014-01-17 09:16   ` Archana K N <archanakknn@gmail.com>
2014-01-17 09:33 ` Mark Kirkwood <mark.kirkwood@catalyst.net.nz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox