Jump to content

INSERT INTO Help


cilian29

Recommended Posts

Good Day! I'm starting to learn postgresql using php and right now I'm stuck being a newbie I have limitted understanding if my query is right. I'm trying to copy all from table1(columnA) and paste all on table2(columnA) using pgadmin iii. I noticed that this cannot be done or I really dont know what I'm doing. so I tried insert into query 

 

INSERT INTO table2(columnA, columnB) VALUES (table1.columnA, table2.columnB)

 

I then follow this with my php code:

 

$sql ="SELECT * FROM table1";

$result = pg_query($dbconn, $sql);

while($row =pg_fetch_array($result)){

 

 

$sql2="INSERT INTO table2(columnA, columnB) VALUES ($row[columnA], $row[columnB])";

$result=pg_query($sql2);

 

 

echo $row[columnA]."<br>";

        echo $row[columnB]."<br>";

 

 

unfortunately I'm not getting results or error. the last error I got is pg_query is not good resource for postgresql. can anyone shed light cuz I'm pulling my hair for days now. thanks in advance.

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.