I want to find all the reruns of a specific production using a string in the query. I do not get any results. This is the query I am trying:
SELECT ?item ?label
WHERE {
?item wdt:P5935 ?id;
rdfs:label ?label.
FILTER(LANG(?label) = "[AUTO_LANGUAGE]").
FILTER(STRSTARTS(?label, "Der Ring des Nibelungen: Die Walküre")).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,en". }
}
Does anyone know how to form queries using a string from the label?
On the Wikidata Query Service website, AUTO_LANGUAGE is replaced by the language of your user inteface.
If your user interface is Dutch, you will get a result: Q47471674.
Otherwise, you don't get a result because no other language has an item with the label "Der Ring des Nibelungen: Die Walküre".
I recommend you to either replace in the FILTER expression AUTO_LANGUAGE by a specific language code or if you want a language independent search, omit the expression altogether.
SELECT ?item ?label
WHERE {
?item wdt:P5935 ?id;
rdfs:label ?label.
# FILTER(LANG(?label) = "nl").
FILTER(STRSTARTS(?label, "Der Ring des Nibelungen: Die Walküre")).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl,en". }
}
Related
I have the following working query with the aim of showing all subclasses of Q3314483 [1]:
SELECT ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?subclass) as ?subklass) (SAMPLE(?subclassLabel) AS ?subLabel) WHERE {
?item wdt:P279* wd:Q3314483 ;
wdt:P279 ?subclass .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
group by ?item
The SAMPLE and GROUP pattern is designed to make the items unique. It seems to work, however the label columns are blank. How can they be displayed?
Based on this
Thanks to #AKSW in the comments. Answer is:
SELECT ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?subclass) as ?subklass) (SAMPLE(?subclassLabel) AS ?subLabel) WHERE {
?item wdt:P279* wd:Q3314483 ;
wdt:P279 ?subclass . SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?subclass rdfs:label ?subclassLabel. ?item rdfs:label ?itemLabel.
}
}
GROUP BY ?item
I'm trying to get the following query in bookshelf's, any ideas? (this query is working and returns the required result)
SELECT "restaurants".*, "meals".*, ( select count(*) from "public"."visitors" as "visitors" where "visitors"."meal_id" = "meals"."id") as "visitorsMealsCount" FROM "public"."restaurants" as "restaurants" inner join "public"."meals" as "meals" ON "meals"."restaurant_id" = "restaurants"."id" WHERE "restaurants"."id" = '123'
Another question, after I'm using belongsTo and hasMany (for example) i expected the return object will be similar to that
restaurants (obj)
meals (obj)
visitorsMealsCount (attribute)
to me your SQL statement doesn't match the concept of an ORM tool like Bookshelf - it neither returns restaurants nor meals, but a grand mixture.
As to your second question: How about using new Restaurant({id: '123'}).fetch({ withRelated: ['meals']}) ?
visitorsMealsCount: In the documentation I see
adminAccounts: function() {
return this.belongsToMany(Account).query({where: {access: 'admin'}});
},
so maybe
visitorsMealsCount: function() {
return this.belongsToMany(Visitor).count();
}
works? (I haven't tried it.)
is possible to make insert, update or delete crossCompany in axapta?
i am trying to do that, debugging in my query i have this:
select forUpdate crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId";
if (tlRemoteLocationInfo.RecId)
{
ttsBegin;
changeCompany(tlRemoteLocationInfo.dataAreaId)
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
i have a try catch, and debugging, fails to update in the method tlRemoteLocationInfo.update(), the exception is:
$exception {"Se produjo una excepción de tipo
'Microsoft.Dynamics.Ax.Xpp.ErrorException'."} System.Exception
{Microsoft.Dynamics.Ax.Xpp.ErrorException}
Am i missing someghing?
You can't do update operations using the crossCompany keyword. See here:
https://msdn.microsoft.com/en-us/library/cc518738.aspx
I rewrote your code so that it should work. And make sure to do an incremental CIL compile if this is running in CIL. The second method is if you wanted to do a while-select.
// Rewrite 1 - Notice removal of "forUpdate"
select firstOnly crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId";
if (tlRemoteLocationInfo)
{
changeCompany(tlRemoteLocationInfo.dataAreaId)
{
// Notice this line
tlRemoteLocationInfo.selectForUpdate(true);
ttsBegin;
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
}
// Rewrite 2 - Is a "while select" what you want?
while select crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId"
{
changeCompany(tlRemoteLocationInfo.dataAreaId)
{
// Notice this line
tlRemoteLocationInfo.selectForUpdate(true);
ttsBegin;
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
}
I mostly use SPARQL SELECT while working on a query for debugging purposes but in the end I want to use the final result it in a CONSTRUCT way; as I want to work with a graph and not key/value query results.
What I don't get yet (and can't seem to find with search engines/docs) is if I can use functions as well that way. As an example, I use a property path to concatenate titles I get into a "superstring", which I later use for building a Lucene index to increase plain text search quality:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT (group_concat(?title ; separator = " ") AS ?fancytitle) WHERE {
GRAPH ?graph {
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> dc:relation+ ?relation .
?relation dc:title ?title .
}
}
Now I would like to have the same ?fancytitleas a new triple like
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> <fancytitle> ?fancytitle .
So I can store it directly in a new graph. Is this possible? I played with some queries but couldn't manage to get it accepted by the SPARQL processor. FYI I'm using Fuseki.
You can try it out at my SPARQL Endpoint
Yes this is possible
You can't use expressions directly in a CONSTRUCT template but you can assign the variable in the WHERE clause either via a SELECT expression in a sub-query or using BIND.
In your case as GROUP_CONCAT is an aggregate it can only be a SELECT expression so you just need to put your entire SELECT as a sub-query e.g.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
CONSTRUCT
{
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> <http://fancyTitle> ?fancytitle
}
WHERE
{
SELECT (group_concat(?title ; separator = " ") AS ?fancytitle) WHERE {
GRAPH ?graph {
<http://data.staatsarchiv-bs.ch/id/archivalresource/CH-000027-1/pa-633c-a-312-fasc-163> dc:relation+ ?relation .
?relation dc:title ?title .
}
}
}
The above works fine on your endpoint
With the help of my colleague we got it to work, UNION and GROUP BY are essential. This query puts the string together for all locah:ArchivalResource in the graphs:
CONSTRUCT
{
?archresource skos:hiddenLabel ?supertitle
}
WHERE
{
SELECT ?archresource (group_concat(?title ; separator = ", ") AS ?supertitle) WHERE {
GRAPH ?graph {
{
SELECT ?title ?archresource WHERE {
GRAPH ?graph {
{
?archresource a locah:ArchivalResource ;
dc:title ?title .
} UNION
{
?archresource dc:relation+ ?relation .
?relation dc:title ?title .
}
}
}
}
}
} GROUP BY ?archresource
}
I can not make a selection via the result of the first
Goal is:
Do the query on the table "line" pick up your ID and search customers that line the "customer" table
This is my code:
db = window.openDatabase("test", "1.0", "Test DB", 1000000);
db.transaction(SelectData,erroSelect,sucessSelect);
function SelectData(tx)
{
tx.executeSql("select id from linha",[],function(tx, response)
{
for(i=0; i<response.rows.length; i++)
{
tx.executeSql("SELECT * FROM customers WHERE line= ?", [response.rows.item(i).id],
function (tx, results)
{
for(r=0; r<results.rows.length; r++)
{
alert(results.rows.item(r).nome); //never worked
}
}
}
},SelectError);
}
It is diffcult to understand from your post, where is the actual error.
Have you tried using console.log() call inside each tx.executeSql() to ascertain that the function is being executed.
Alternatively you can use a single query instead of using two SELECT statements.
Replace
select id from linha
with
SELECT customers.columnName1, customers.columnName2
FROM customers INNER JOIN linha ON customers.line = linha.id