简体   繁体   中英

Creating a triple store query using SQL - how to find all triples that have a common predicate and object

I have a database that acts like a triple store, except that it is just a simple MySQL database.

I want to select all triples that have a common predicate and object. Info about RDF and triples

I can't seem to work out the SQL.

If I had just a single predicate and object to match I would do:

select TRIPLE from TRIPLES where PREDICATE="predicateName" and OBJECT="objectName"

But if I have a list (HashMap) of many pairs of (predicateName,objectName) I am not sure what I need to do.

Please let me know if I need to provide more info, I am not sure that I have made this quite clear, but I am wary of providing too much info and confusing the issue.

可能将您的哈希图加载到临时表中,然后对三元组存储进行JOIN

select TRIPLE from TRIPLES where PREDICATE in (?,?,?,........) and OBJECT in (?,?,?,?,.....)

Populate the `?'s using HashMap.keys and HashMap.values. Depending on language and data-access method, use either bound parameters (ODBC and other methods) or expand the parameters building up the sql yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM