Solved

run column2 through a function and output would be in column3

Posted on 2014-02-17
3
209 Views
Last Modified: 2014-02-17
using mysqli, or pdo

I would like a php function that prepends 'begin' and postpends 'end' to an existing varchar field

table.column1 int primary key autoincrement
table.column2 varchar
table.column3 varchar


example output
5454  begin5454end
656    begin656end
4        begin4end
A        beginAend
0
Comment
Question by:rgb192
3 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 500 total points
ID: 39865494
UPDATE table SET column3 = CONCAT("begin",column2,"end")
0
 

Author Closing Comment

by:rgb192
ID: 39865507
yes that works using only mysql.
Thank you.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39865535
I guess you could write a function, but it might be easier to write a single line PHP statement like this:

$old = '5454';
$new = 'begin' . $old . 'end';
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question