当前位置: 代码迷 >> ColdFusion >> -超难有关问题-
  详细解决方案

-超难有关问题-

热度:1127   发布时间:2013-02-26 00:00:00.0
---------------超难问题-------------------------
SELECT restaurantid
FROM (select distinct restaurantid,regionid from restaurant_region)
WHERE instr('01,02',regionid)>0
GROUP BY restaurantid
HAVING (count( regionid) = len('01,02')-len(replace('01,02',',',''))+1)
说明:上面的语句在access中正确执行!!!
-----------------------------------------
<cfset strSQL="SELECT restaurantid
FROM (select distinct restaurantid,regionid from restaurant_region)
WHERE instr('01,02',regionid)>0
GROUP BY restaurantid
HAVING (count( regionid) = len('01,02')-len(replace('01,02',',',''))+1)">
<cfquery datasource="antx" name="test">
#PreserveSingleQuotes(strSQL)#
</cfquery>
------------------------------------
上面的程序即报错!!
提示信息:
Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] 表达式中 'replace' 函数未定义。  
为什么?replace是access的内置函数呀!!!!

------最佳解决方案--------------------------------------------------------
说说怎么搞定的。
------其他解决方案--------------------------------------------------------
<body>
<cfset RegionIdCounts=len('01,02')-len(replace('01,02',',','',"All")+1)>

<cfset strSQL="SELECT restaurantid
FROM (select distinct restaurantid,regionid from restaurant_region)
WHERE instr('01,02',regionid)>0
GROUP BY restaurantid
HAVING (count( regionid)=#RegionIdCounts#)
">
<cfquery datasource="antx" name="test">
#PreserveSingleQuotes(strSQL)#
</cfquery>
<cfoutput query="test">
#restaurantid#
</cfoutput>
</body>
------其他解决方案--------------------------------------------------------
问题搞定!!!
  相关解决方案