如何将CONCAT_WS与IN一起使用? [英] How do I use CONCAT_WS together with IN?

查看:140
本文介绍了如何将CONCAT_WS与IN一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Symfony2和Doctrine2,想将CONCAT_WS与IN结合,而不是写入很多IF。

Using Symfony2 and Doctrine2, want to combine CONCAT_WS with IN, rather than write a lot of IF's.

WHERE CONCAT_WS('-', id2, id2) IN ($ids)

我收到这个错误: p>

I am receiving this error:

[Syntax Error] line 0, col 446: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_IN, got '('

$ ids的形式是123-456。

$ids are in form of '123-456'.

如果我只是使用列而不是CONCAT_WS,它的工作原理是:

If I simply use a column instead of CONCAT_WS, it works:

WHERE id2 IN ($ids)


推荐答案

MySQL功能可以在Doctrine中使用,只有支持所有数据库的功能才可用。

Not all MySQL functions are available for use in Doctrine. Only those functions that are common to all databases supported are available.

按照此链接可以查看默认情况下可用的功能列表< a href =http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#functions-ope rators-aggregatesrel =nofollow> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#functions-operators-aggregates 。

Follow this link to see the list of functions available by default http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#functions-operators-aggregates .

如果要使用CONCAT_WS,请阅读以下链接中的创建自定义功能。您可以创建自己的DQL自定义功能,并且可以像以前尝试的那样使用。

If you want to use CONCAT_WS anyway, read about creating custom functions on the following links. You can create your own DQL Custom Function and will be able to use just like you tried before.

http://docs.doctrine-project.org/projects/doctrine-orm/en/最新/ cookbook / dql-user-defined-functions.html

http://symfony.com/doc/current/cookbook/doctrine/custom_dql_functions.html

这篇关于如何将CONCAT_WS与IN一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆