因此,我正在處理一個查詢,該查詢將獲得申請人的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