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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.