Sparql Select 带条件查询
Sparql Select query with condition
我正在做一个 sparql 查询,我需要知道如何在 where 子句中放置一个条件,假设它 returns M(Male),F (Female),我想绑定字母 (M ) 到男字,(F) 和女字。
我是 sparql 的新手,我使用 sql,我需要在 sparql 中找到类似的东西:
Case when Gender = 'M' then 'Male' when Gender = 'Female' then 'Female'
我的查询简化了更多更少这个:
SELECT DISTINCT ?Gender count(distinct ?publication)
FROM href
WHERE {
?publication a href.
?publication href ?AuthorList.
?AuthorList?item ?Person.
?Person foaf:gender ?genero //Need here the condition
}
最后我用这段代码搞定了:
SELECT ?Sexo count(distinct ?publication)
FROM href
WHERE {
?publication a href.
?publication < href ?listaAutores.
?listaAutores ?item ?persona.
?persona foaf:gender ?gender
BIND(
IF(contains(?gender, "f"), "Female",
"Male")
AS ?Sexo).
}
我正在做一个 sparql 查询,我需要知道如何在 where 子句中放置一个条件,假设它 returns M(Male),F (Female),我想绑定字母 (M ) 到男字,(F) 和女字。
我是 sparql 的新手,我使用 sql,我需要在 sparql 中找到类似的东西:
Case when Gender = 'M' then 'Male' when Gender = 'Female' then 'Female'
我的查询简化了更多更少这个:
SELECT DISTINCT ?Gender count(distinct ?publication)
FROM href
WHERE {
?publication a href.
?publication href ?AuthorList.
?AuthorList?item ?Person.
?Person foaf:gender ?genero //Need here the condition
}
最后我用这段代码搞定了:
SELECT ?Sexo count(distinct ?publication)
FROM href
WHERE {
?publication a href.
?publication < href ?listaAutores.
?listaAutores ?item ?persona.
?persona foaf:gender ?gender
BIND(
IF(contains(?gender, "f"), "Female",
"Male")
AS ?Sexo).
}