Using concat to return 2 (or more) MySQL fields as one

If you have field one and field two but need to return them as a single new field then you need concat:

$sql = "concat(fieldone, ' (', fieldtwo,')') as newfield  FROM table";

This example when echoing newfield will display fieldone (fieldtwo)

Tags: ,

About Keiron

Web Developer based in the UK. Click here if you want to work with me