Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

MySQL Variable Assignment

Code in PHP

7:30 am on Sep 16, 2008 (gmt 0)

New User

10+ Year Member

joined:Sept 16, 2008
votes: 0

Hello all,
I am Fakher and I am just in learning phase of PHP and MySQL so i need you help on a few issues.

I have two tables in same Database with two different with same name but different table prefixes of course.....



these are two tables now they have their variables which are same in data type to each other ....

now what i want is to assign all the variables from "myprefix_table" to "youprefix_table".

Means any change or upgrade to "myprfix_table" should be copied to "yourprfix_table"

So how can i do that in PHP or in SQL?
i dnt know where should it be done ?
so i need you help :(

10:28 am on Sept 16, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:June 6, 2005
votes: 0

Gday Fakher, welcome :)

The quickest way to do this would be to delete the data in yourprefix_table, then copy the data from myprefix_table. You can do that with two SQL queries:

"DELETE FROM yourprefix_table"
"INSERT INTO yourprefix_table SELECT * FROM myprefix_table"

4:56 pm on Sept 16, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 12, 2007
votes: 0

So how can i do that in PHP or in SQL?
i dnt know where should it be done ?

You could do it in either. Generally I would suggest using SQL as it is more likely that the server running your database will be under less load than the web server...although that may not be true in your setting so check.

Using 2 SQL statements in the PHP code is one way to do it. You could also use a procedure within the database to do the work for you automatically; this would be the most efficient. You would have to write that procedure in one of the languages that your database works with, so while this would be the most efficient it may not be something that you want to do if you dont code in any of those languages.

Just noticed that was your first post, so welcome along :)

[edited by: PHP_Chimp at 4:57 pm (utc) on Sep. 16, 2008]

1:05 am on Sept 18, 2008 (gmt 0)

New User

10+ Year Member

joined:Sept 16, 2008
votes: 0

Well thank you MattAU and PHP_Chimp for you kind responce......

I have a problem using these two SQL queries that i cant delete any of the table.

oki lemme me tell you in detail now.
I am using two PHP scripts. In both scripts user can register separately in different tables.

what i have done is "I have installed both of the scripts in one Database with different prefixes."

Now i want to use just one single same users table for both scripts.

Users who registered on one script can login to other with same username and password.

So i just want to merge at least users table.
i think now you get me?

[edited by: Fakher at 1:38 am (utc) on Sep. 18, 2008]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members