我制作了一个 PostgreSQL 表,其中包含来自牛津大学政府响应跟踪器处理 COVID-19 的数据。
如果有人感兴趣,这里是数据源的链接。
您可以下载 JSON 或 CSV;就我而言,我使用的是 CSV 格式。
该文件具有以下列:
CountryName
CountryCode
Date
C1_School closing
C1_Flag
C2_Workplace closing
C2_Flag
C3_Cancel public events
C3_Flag
C4_Restrictions on gatherings
C4_Flag C5_Close public transport
C5_Flag
C6_Stay at home requirements
C6_Flag
C7_Restrictions on internal movement
C7_Flag
C8_International travel controls
E1_Income support
E1_Flag
E2_Debt/contract relief
E3_Fiscal measures
E4_International support
H1_Public information campaigns
H1_Flag
H2_Testing policy
H3_Contact tracing
H4_Emergency investment in healthcare
H5_Investment in vaccines
M1_Wildcard
ConfirmedCases
ConfirmedDeaths
StringencyIndex
StringencyIndexForDisplay
StringencyLegacyIndex
StringencyLegacyIndexForDisplay
GovernmentResponseIndex
GovernmentResponseIndexForDisplay
ContainmentHealthIndex
ContainmentHealthIndexForDisplay
EconomicSupportIndex
EconomicSupportIndexForDisplay
回到问题,所以我想创建一个简单的 SQL 查询,比如这个
SELECT * FROM govt_respond_tracker
WHERE countryname in ('list_of_african_countries')
Order BY countryname ASC,
datec ASC;
这个查询的想法是调用文件中所有可用的非洲国家。
然而,当我要称呼“Cote d'Ivoire”(象牙海岸)时,问题就出现了。
单引号会导致错误,阻止返回我想要的结果。
我想要的这个结果只是 SQL 输出,其中包含“Cote d'Ivoire”作为其在 SQL 输出中的值。
那么,我的问题是我解决这个问题的最佳方法是什么?
非常感谢您的宝贵时间!