Hi ,
I am trying to achieve so that latest one will be at top , I have Union query which merge two table , now order by descneding on primary key will not work as both might have differnt numbers and whatver comes next doesnt needs to be higher one , as they have differnt data count ,
below is what i was trying
var query = " SELECT * FROM ( " +
" SELECT '1' AS Type, c.StartDate, ifnull(cu.FirstName,'') AS FirstName, ifnull(cu.LastName,'') AS LastName,c.ClientComBox, c.DeviceCallID AS CallID " +
" FROM Call c " +
" LEFT OUTER JOIN Customer cu ON c.CustomerID = cu.CustomerID " +
" UNION " +
" SELECT '2' AS Type, c.StartDate, ifnull(cu.FirstName,'') AS FirstName, ifnull(cu.LastName,'') AS LastName,c.ClientComBox, c.DeviceChemistCallID AS CallID " +
" FROM ChemistCall c " +
" LEFT OUTER JOIN Customer cu ON c.CustomerID = cu.CustomerID " +
" ) c WHERE 1 = 1";
if (searchText != null && searchText != undefined && searchText.length > 0) {
query += " AND (FirstName like '%" + searchText + "%'" +
" OR LastName like '%" + searchText + "%' " +
" OR ClientComBox like '%" + searchText + "%') ";
}
query += " ORDER BY c.CallID DESC LIMIT ? , ?";
Please suggest , so that whicver is latest will come at top