У меня следующий запрос SQL:
SELECT mshipType_Name,
COUNT('x') AS mshipssold,
sum(memberToMship_InductionFee+memberToMship_JoinFee+
(IF(mshipOption_Period='year',
TIMESTAMPDIFF (YEAR ,memberToMship_StartDate, memberToMship_EndDate),
TIMESTAMPDIFF (MONTH ,memberToMship_StartDate, memberToMship_EndDate)) * memberToMship_ChargePerPeriod)) as value
FROM membertomships
INNER JOIN mshipoptions on membertomships.mshipOption_Id = mshipoptions.mshipOption_Id
INNER JOIN mshiptypes on mshipoptions.mshipType_Id = mshiptypes.mshipType_Id
WHERE memberToMship_StartDate BETWEEN '2011-06-26' AND '2011-07-26'
GROUP BY mshipType_Name;
Результаты будут отображаться так:
mshiptype_name mshipsold value
-------------- --------- -----
gold 3 3800.00
silver 4 4800.00
Хорошо, я могу получить результаты, подобные этому, с добавленным в значение символом фунта:
mshiptype_name mshipsold value
-------------- --------- -----
gold 3 £ 3800.00
silver 4 £ 4800.00
Возможно ли это с запросом MySQL?
ИЗМЕНЕННЫЙ ЗАПРОС:
SELECT set names utf-8,mshipType_Name, COUNT('x') AS mshipssold,
CONCAT('£', sum(memberToMship_InductionFee+memberToMship_JoinFee+
(IF(mshipOption_Period='year',
TIMESTAMPDIFF (YEAR ,memberToMship_StartDate, memberToMship_EndDate),
TIMESTAMPDIFF (MONTH ,memberToMship_StartDate, memberToMship_EndDate)) * memberToMship_ChargePerPeriod))) as value
FROM membertomships
inner join mshipoptions on membertomships.mshipOption_Id = mshipoptions.mshipOption_Id
inner join mshiptypes on mshipoptions.mshipType_Id = mshiptypes.mshipType_Id
WHERE memberToMship_StartDate BETWEEN '2011-06-26' AND '2011-07-26'
GROUP BY mshipType_Name;
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set names utf-8,mshipType_Name, COUNT('x') AS mshipssold,
' at line 1