Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying one table into another ... ? 1

Status
Not open for further replies.

dbeezzz

Technical User
Nov 30, 2005
54
KR
So I have a styles table which serves as a kinda template for my styles on my php app. I want my users to be able to copy styles into themes and hammer away on their themes settings themselves if they so wish.

Can I just copy one set of data into another using one sql statement ?

Something like ...
Code:
$sql = "SELECT * 
				FROM ".STYLES_TABLE."
					WHERE style_id = $style_id
			AND 
				INSERT INTO ".THEMES_TABLE."
					VALUES *
						WHERE user_id = $user_id 
							
					";

$sytles_id and $user_id are session varables available in global scope btw
 
You could use something like:
[tt]
INSERT themestable
SELECT $user_id,*
FROM stylestable
WHERE style_id=$style_id
[/tt]
The SELECT must result in a record which can be inserted without modification into themestable, so you might need to list the fields individually.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top