Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Merge issue

Codes here !

Moderators: macek, egami, gesf

Merge issue

Postby Guerlot » Sat Oct 05, 2002 6:54 am

If I have this line in a PHP page:

$result = mysql_query("SELECT value1,value2,value3 FROM $table ORDER BY value1");

Is there a way to merge the content of the 3 columns into one (let's call it value4) and order the results with that new value?

somebody told me about a "concat" function but I'm not sure about it
Guerlot
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Oct 05, 2002 6:47 am
Location: Hull, Quebec, Canada

Postby DoppyNL » Sat Oct 05, 2002 7:32 am

you can use concat:
Code: Select all
SELECT concat(`field1`,`field2`,`field3`) as `workname` FROM `sometable` ORDER BY `field1`;

this will return all records from the table and only one column named "workname" wich is field1 + field2 + field3.

See also Mysql Manual - Function Concat

Greetz Daan
DoppyNL
 


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron