尝试将货币符号添加到MySQL
我有以下 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
Is it possible with a MySQL query?
修改后的查询:
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
I have the following SQL query:
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;
It will show the results like this:
mshiptype_name mshipsold value
-------------- --------- -----
gold 3 3800.00
silver 4 4800.00
Its fine can I get the results like this with pound symbol has added in value:
mshiptype_name mshipsold value
-------------- --------- -----
gold 3 £ 3800.00
silver 4 £ 4800.00
Is it possible with a MySQL query?
MODIFIED QUERY :
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,尝试使用:
Yes, try with: