Jump to content

Inserting variable into new column


mikebyrne

Recommended Posts

I currently have a database of names and addresses which looks like this:

 

,1,Caxxan,Cathy,Wxxxde,Ardreigh,Axy,Co.xxxe

,2,Caxxan,Liam,Wxxxde,Ardreigh,Axy,Co.xxxe

,3,Caxxan,Margaret,Wxxxde,Ardreigh,Axy,Co.xxxe

 

I want to run a piece of php that will insert "The $Sname Family" in a new column where $Sname is the varible of the surname of that row.

 

Any idea how I can code this??

 

 

Link to comment
https://forums.phpfreaks.com/topic/184522-inserting-variable-into-new-column/
Share on other sites

Assuming mysql, execute this query (substituting your actual column names) to update your new column with the concatenation of - 'The ', your Sname column values, and ' Family' -

UPDATE your_table SET your_new_column = CONCAT('The ', Sname, ' Family')

 

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.