---------------超难问题-------------------------
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>
[其他解释]
问题搞定!!!