如何使用Haskell中的Esqueleto实现MySQL的group_concat?

发布于 2025-02-04 12:01:49 字数 530 浏览 4 评论 0原文

我需要找出如何在Haskell中的Esqueleto下实现MySQL的group_concat。 Esqueleto功能应看起来像以下内容,但此版本适用于SQLite。因此,我需要MySQL的工作解决方案:

sqliteGroupConcat ::
     PersistField a
  => SqlExpr (Value a)
  -> SqlExpr (Value a)
  -> SqlExpr (Value Text)
 -- sqliteGroupConcat (t ^. BookmarkTagTag) (val " ") 
sqliteGroupConcat expr sep = unsafeSqlFunction "GROUP_CONCAT" [expr, sep]

由于MySQL版本中的输入未分开,因此我无法使用此group_concat函数。 MySQL的Group_Concat函数应该能够执行以下SQL函数:

GROUP_CONCAT(country SEPARATOR ';')

I need to find out how to implement MySql's Group_Concat under Esqueleto in Haskell. The esqueleto function should look like the following but this version is suitable for Sqlite. So I need a working solution for Mysql:

sqliteGroupConcat ::
     PersistField a
  => SqlExpr (Value a)
  -> SqlExpr (Value a)
  -> SqlExpr (Value Text)
 -- sqliteGroupConcat (t ^. BookmarkTagTag) (val " ") 
sqliteGroupConcat expr sep = unsafeSqlFunction "GROUP_CONCAT" [expr, sep]

I cannot use this group_concat function for mysql as the inputs in mysql's version aren't comma separated. The group_concat function for mysql should be able to perform the following sql function:

GROUP_CONCAT(country SEPARATOR ';')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文