在 Sparql 中按字符串过滤 SELECT 输出
Filter SELECT output by string in Spaql
我有一个这样的 Sparql 查询:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX hrdata:<http://www.hrdata.com/ontologies/hrdata.owl#>
SELECT ?tableName2 ?fieldName ?primaryKey1 ?primaryKey2 ?tableName1
WHERE { ?tableName1 hrdata:hasField hrdata:EFFDT.
?fieldName hrdata:relatedField hrdata:EFFDT.
?tableName2 hrdata:hasField ?fieldName.
?primaryKey1 hrdata:isPrimaryKey ?tableName1.
?primaryKey2 hrdata:isPrimaryKey ?tableName2.
}
它 returns 对我来说是一长串不同的 table 名字,因为它们有相同的 属性 和名字 'EFFDT'。
我想在这样的地方添加另一个条件,告诉它我的意思是那些与名称为 'xyz':
的 table 相关的 'EFFDT'
Filter ( ?tableName1 = 'xyz')
我 google 很多,但不幸的是 none 下一页中的解决方案可能对我有帮助。
你有什么想法吗?
?tableName1
在主题位置是 URI 还是空白节点。
Filter ( ?tableName1 = 'xyz')
测试字符串。
如果您的意思是 URI 包含字符串 xyz
那么:
Filter ( contains(str(?tableName1),'xyz'))
我有一个这样的 Sparql 查询:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX hrdata:<http://www.hrdata.com/ontologies/hrdata.owl#>
SELECT ?tableName2 ?fieldName ?primaryKey1 ?primaryKey2 ?tableName1
WHERE { ?tableName1 hrdata:hasField hrdata:EFFDT.
?fieldName hrdata:relatedField hrdata:EFFDT.
?tableName2 hrdata:hasField ?fieldName.
?primaryKey1 hrdata:isPrimaryKey ?tableName1.
?primaryKey2 hrdata:isPrimaryKey ?tableName2.
}
它 returns 对我来说是一长串不同的 table 名字,因为它们有相同的 属性 和名字 'EFFDT'。 我想在这样的地方添加另一个条件,告诉它我的意思是那些与名称为 'xyz':
的 table 相关的 'EFFDT'Filter ( ?tableName1 = 'xyz')
我 google 很多,但不幸的是 none 下一页中的解决方案可能对我有帮助。
你有什么想法吗?
?tableName1
在主题位置是 URI 还是空白节点。
Filter ( ?tableName1 = 'xyz')
测试字符串。
如果您的意思是 URI 包含字符串 xyz
那么:
Filter ( contains(str(?tableName1),'xyz'))