I have a stored procedure that takes data from multiple tables. The stored procedure is called from a PHP script and the resulting data is placed in a grid.
The issue I'm having is I'm not sure how to get the dayname to be unique so that at maximum there are seven columns, one for each day of the week, as opposed to getting results like 'Tuesday' and 'Tuesday1'
Here is a snippet
select concat(
'select tbl_kiosks.name "DCI ERP",tbl_retailers.abbr "Retailer",
tbl_retaillocations.storeNumber "Store",
tbl_retaillocations.city "City",
tbl_retaillocations.state "State"'
, group_concat(
concat(',sum(if(ks.StartDate="',ks3.StartDate,'", numOfSessions, null)) "', dayname(DATE_FORMAT(ks3.StartDate,'%Y-%m-%d')) ,'" '
)
separator ' '
)