SELECT id, CONCAT(lastname,', ',firstname) AS fullname, lastname, firstname
FROM " . TABLE_CONTACT . "
WHERE
CONCAT(firstname,' ', lastname) LIKE '%$goTo%' OR
CONCAT(firstname,' ', middlename,' ', lastname) LIKE '%$goTo%' OR
nickname LIKE '%$goTo%'
ORDER BY fullname";
Can anyone please tell me what is purpose of above query ? I am new to mysql so unable to understand it. Thanks
It will query the DB and get the
idand create a full nameCONCAT(lastname,', ',firstname)from both first and last name fields and also return them separatelylastname, firstnameFROM the contacts table
TABLE_CONTACTWHERE the variable passed
%$goTo%should match:Imagine this record in the DB:
1-
CONCAT(firstname,' ', lastname)=Ibrahim Faour2- OR
CONCAT(firstname,' ', middlename,' ', lastname)=Ibrahim Ali Faour3-
nickname=ifaourAnd them order them by the newly created column
fullname