[Developers] MQL equivalent of SQL's SELECT DISTINCT?
Christopher R. Maden
crism at metaweb.com
Wed Feb 20 22:30:03 UTC 2008
Jonathan W. Lowe wrote:
> 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).
>
> Is there an MQL "shortcut" equivalent to SQL's SELECT DISTINCT?
The trick to this, in MQL, is to turn the query inside out.
You want to find all types who 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 in there to keep it more readable and to decrease
the likelihood of timeout.)
~Chris
--
Christopher R. Maden
Data Architect
Metaweb Technologies, Inc.
<URL: http://www.metaweb.com/ >
More information about the Developers
mailing list