Page 1 of 2
Copy
Posted: Mon Dec 29, 2003 5:27 pm
by Straterra
How would I copy everything from one table to another?
Posted: Tue Dec 30, 2003 10:41 am
by AVATAr
create a table: copy_table
and then:
SELECT * INTO copy_table FROM table
Posted: Tue Dec 30, 2003 1:12 pm
by Straterra
Code: Select all
sqlite_query($db, "SELECT * INTO clanprofile2 FROM clanprofile");
That doesn't seem to work at all... I get this message
Warning: sqlite_query(): near "INTO": syntax error in c:\ftp\users\straterra\eck\cgi-bin\full1.php on line 32
Posted: Tue Dec 30, 2003 1:38 pm
by AVATAr
did you create the table clanprofile2?
Posted: Tue Dec 30, 2003 1:38 pm
by Straterra
Yes, the table is created.
Posted: Tue Dec 30, 2003 1:51 pm
by AVATAr
Maybe its not supported by sql-lite.
check this:
http://www.w3schools.com/sql/sql_select_into.asp
Posted: Tue Dec 30, 2003 2:04 pm
by Straterra
http://www.hwaci.com/sw/sqlite/omitted.html
That website says to add collumns, you have to copy the current into a temporary table...(ALTER TABLE To change a table you have to delete it (saving its contents to a temporary table) and recreate it from scratch. ) I wanted to copy so that I could add collumns. But, how can I move the current table to a new table when SQLite doesn't support the fricking SELECT * INTO clanprofile2 FROM clanprofile thing...
Posted: Tue Dec 30, 2003 2:07 pm
by AVATAr
good point..
1- make a php script.. with select in one table and insert in other
2- why are you using sqllite?
Posted: Tue Dec 30, 2003 2:10 pm
by Straterra
AVATAr wrote:good point..
1- make a php script.. with select in one table and insert in other
2- why are you using sqllite?
I don't understand what you mean with your first point. But the reason I use SQLite is because it's both smaller and faster than MySQL. Also, it doesn't eat system resources, like MySQL does. I have an older server, so I found SQLite to be quite friendly. This is the only problem I have ever had with SQLite.
Posted: Tue Dec 30, 2003 2:15 pm
by AVATAr
1- make a php script with a select * and then make a foreach in that resource and insert those values in the new table.
How many records?
Posted: Tue Dec 30, 2003 2:17 pm
by Straterra
God..that could take a while. I suck at foreach's...Lemme try to write something really quickly. The table has maybe 10 rows..and perhaps 15 collumns.
Posted: Tue Dec 30, 2003 2:22 pm
by AVATAr
10 rows... it will be very quick!
Posted: Tue Dec 30, 2003 2:23 pm
by Straterra
Since I am such a newbie..could you tell me if I am on the right path?
Code: Select all
$result = (sqlite_query($db, "SELECT * from clanprofile"));
foreach ($result as $rst2) {
Posted: Tue Dec 30, 2003 2:31 pm
by Straterra
I currently have this
Code: Select all
$result = (sqlite_query($db, "SELECT * from clanprofile"));
$row=sqlite_fetch_array($result);
foreach ($row as $rst2) {
echo $rst2;
}
Weird..It only prints like one row..What did I do wrong?
Posted: Tue Dec 30, 2003 2:49 pm
by Straterra
I think I have it figured out now. Thank you SO MUCH for your help. After I get done, I will write a tutorial on how to do it!