因此,我正在处理一个查询,该查询将获得申请人的first_name_txt,last_name_txt或business business_name。SQL concat和转义字符
我在试图连接逗号时遇到问题。
case
when (credit_req_contr_requestor.requestor_type_id=0)
then CONCAT(CONCAT(credit_req_contr_requestor.last_name_txt,'','') ,
credit_req_contr_requestor.first_name_txt)
when(requestor_business.requestor_type_id=3)
then requestor_business.business_name_txt end as applicant_name_txt
我给两个单引号的原因是因为查询由Java SQL加载运行,当它遇到一个单引号打破。
但是,当我运行这个查询时,它给出了一个错误说“无效的争论数量”。所以,我添加了三个单引号''','''
,但是然后applicant_name_txt将显示为Smith',' John
。
我试过使用||而不是concat,这也是同样的问题。
我该如何解决这个问题?如何在显示时在这两个字段之间添加逗号?我可以使用任何其他转义字符?
我希望你不抱怨'了mystring =“选择...‘喇嘛’...”'不工作 - 因为在这种情况下,你应该转义[Java字符串字符](http://docs.oracle.com/javase/tutorial/java/data/characters.html),而不是SQL - 即''... \'bla \'...“或''''bla'...''' – Aprillion 2012-03-09 22:32:39