Need help on update.
От | Nicholas I |
---|---|
Тема | Need help on update. |
Дата | |
Msg-id | AANLkTi=nyWz=SNYZ+uLNPeUKOTgSscVqZR6CRTUkL99z@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Need help on update.
|
Список | pgsql-sql |
Hi, <br /><br />there are two tables, table1 and table2, each having same column name called sn_no,name. i want to updatetable1 names with table2 where sn_no are same.<br /><br />select * from table1;<br />sn_no | name <br />-------+-----------<br/> 1 | ramnad<br /> 2 | bangalore<br /> 3 | chennai<br /><br /><br />select * from table2;<br/> sn_no | name <br />-------+-----------<br /> 1 | Hyderabad<br /> 2 | Delhi<br /> 3 | Bombay<br/><br />Any help ?<br /><br /> I tried with , some of the queries like, <br /><br /><b>UPDATE table1 SET name =(select name from table2) where table2.sn_no = table1.sn_no;</b><br />ERROR: missing FROM-clause entry for table "table2"<br/>LINE 1: ...table1 SET name = (select name from table2) where table2.sn_.<br /><br /><b>UPDATE table1 inner jointable2 on table2.sn_no = table1.sn_no set <a href="http://table2.name">table2.name</a> = <a href="http://table1.name">table1.name</a>;</b><br/>ERROR: syntax error at or near "inner"<br /> LINE 1: UPDATE table1 innerjoin table2 on table2.sn_no = table1.sn_...<br /><br />-Nicholas I<br /><br /><br />
В списке pgsql-sql по дате отправления: