【发布时间】:2021-10-03 22:18:35
【问题描述】:
至少可以说,我对 QofQ 的体验是有限的。我真的可以使用一些帮助,而不是给任何借口。先感谢您。为了让事情更清楚,我摆脱了许多简单的搜索要求,但不知不觉 20 并不是选择企业的唯一标准。
我有两个数据库,一个用于存储商店及其信息,另一个用于存储营业时间。理想情况下,我想将商店的结果与商店营业时间合并。注意:并非所有商店都有营业时间,而且商店营业时的日期或营业时间也不相同,因此当我查找营业时间表时,我会从列表中查找与“businessID”和“dayWeek”匹配的结果“营业时间”数据库。
数据库:
- “企业”包含 id [Key]、bus_name、bus_address、bus_city、bus_phone。我将结果限制为每页 20 个(显然 20 被变量替换)
数据示例:
- 1001, ABC, 123 Main Street, New York, 212-555-1212
- 1002, NBC, 246 Elm Street, Long Island, 516-555-1212
- 1003, CBS, 369 Ave P, Brooklyn, 718-555-1212
- “hoursopen”包含 id [Key]、“businessID”匹配数据库“businesses”id [Key]、timeZone(调整时区)、dayWeek(仅选择今天的小时数)、openTime 和 closeTime 数据示例:
- 3、1001、1、5、09:00:00、21:00:00
- 4、1001、1、6、09:00:00、21:00:00
- 5、1001、1、7、10:00:00、16:00:00
代码:
<cfquery name="businesses" datasource="businesses">
SELECT id, bus_name, bus_address, bus_city, bus_phone
FROM businesses
WHERE id < 20
</cfquery>
<!-- 1st Query businesses (id) that were found to search in the hoursopen database,
note that the two results are not in the same order-->
<cfscript>
businessResults=ValueList(businesses.id)
</cfscript>
<cfquery name="hoursopen" datasource="hoursopen">
SELECT *
FROM hoursopen
WHERE businessID IN (
<cfqueryparam
value="#businessResults#"
cfsqltype="CF_SQL_INTEGER"
list="yes"
/>
) AND dayWeek = dayOfWeek(Now())
</cfquery>
<!-- In the results I bolded the BusinessID to Illustrate the relationship.-->
<p>------ BUSINESS LOCATION & PHONE ------ </p>
<cfoutput query="businesses">
<strong>Business ID: #id#</strong><br/>
Business Name: #bus_name#<br/>
Address: #bus_address#<br/>
City: #bus_city#<br/>
Phone: #bus_phone#<br/>
<hr/>
</cfoutput>
<p>------ BUSINESS HOURS ------ </p>
<cfoutput query = "hoursopen">
<p>ID: #id# | <strong>Business ID: #businessID# </strong>| Time Zone: #timeZone# |
Day of the Week: #dayWeek# | Store Opens: #openTime# | Store Closes: #closeTime#</p>
<hr/>
</cfoutput>```
【问题讨论】:
标签: coldfusion coldfusion-2016