Merge issue

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 4
Joined: Sat Oct 05, 2002 6:47 am
Location: Hull, Quebec, Canada

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


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

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 3 guests