From a question posted to the Developer's email list:
I'm trying to form an MQL read query that specifies a type (e.g. /business/company), finds all topics of that type, lists all other types linked to those topics, and returns a distinct list of those other types (as per a SQL SELECT DISTINCT... query).The trick to this, in MQL, is to turn the query inside out.
Is there an MQL "shortcut" equivalent to SQL's SELECT DISTINCT?
You want to find all types that have instances shared with a target type /business/company.
{
"query":[
{
"type":"/type/type",
"name":null,
"id":null,
"instance":[
{
"type":"/business/company",
"limit":1
}
]
}
]
} (The limit clause is included to improve the readability of the result and to decrease the likelihood of timeout.)
Search Help Center
Discussions
There are no conversations on this topic. Would you like to start one?
Start the Discussion »- Building Bases
- Creating Schemas
-
Developing Applications
- An Introduction to Freebase Application Development
- Playing in the Sandbox
- Freebase Programming Libraries and Tools
- Data Dump FAQ
- Using the Query Editor
- The Complete Metaweb Query Language (MQL) Reference Guide
- MQL Cheatsheet
-
The MQL Cookbook
- Get data as of a specific time
- Read properties of a type
- values vs name/id
- Incoming links
- Any topics with a specific date
- Wikipedia article text
- Retrieve the Wikipedia URL for an object with a GUID
- Find distinct co-types
- Creating relationships with the connect directive
- Mark for deletion
- Sort by index and timestamp
- Traversing Through Non-Reversed Properties
- Combine queries
- Perform transitive queries
- Freebase API Reference
- Application Developer Tips
- The Acre Hosted Development Environment
- Introduction to the Metaweb Javascript Template Language (MJT)
- Freebase Community