CMIS search is there a way to search for all
In SQL it would be
select ID
from mvTo
where name in ('john', 'sally', 'same')
group by ID
having count(*) = 3
assume unique index on name
If you have a single-value property, such as cmis:createdBy, you can write a query that matches on any value in a list, like this:
SELECT * FROM cmis:document where cmis:createdBy in ('jpotts', 'admin', 'tuser1')
If you have a multi-value property, and you want to match if any of the values match, you can use the ANY keyword, like:
SELECT * FROM cmis:document where ANY sc:someMultiValuedProp in ('val1', 'val2', 'val3')
Group by is not supported.
For more information on what you can do with CMIS queries, read the Query Language Definition section of the CMIS specification.
Related
Postgresql select query containing tuple with single quotes as well as double quotes when giving this tuple as the input to select query it genrates error stating that specific value is not present in the database.
I have treid converting that list of values to JSON list with double quotes but that doesn't help either.
list = ['mango', 'apple', "chikoo's", 'banana', "jackfruit's"]
query = """select category from "unique_shelf" where "Unique_Shelf_Names" in {}""" .format(list)
ERROR: column "chikoo's" doesn't exist
Infact chikoo's does exist
But due to double quotes its not fetching the value.
Firstly please don't use list as a variable name, list is a reserved keyword and you don't wanna overwrite it.
Secondly, using "" around tables and columns is bad practice, use ` instead.
Thirdly, when you format an array, it outputs as
select category from `unique_shelf`
where `Unique_Shelf_Names` in (['mango', 'apple', "chikoo's", 'banana', "jackfruit's"])
Which is not a valid SQL syntax.
You can join all values with a comma
>>>print("""select category from `unique_shelf` where `Unique_Shelf_Names` in {})""".format(','.join(l)))
select category from `unique_shelf`
where `Unique_Shelf_Names` in (mango,apple,chikoo's,banana,jackfruit's)
The issue here is that the values inside the in bracket are not quoted. We can do that by formatting them beforehand using double quotes(")
l = ['mango', 'apple', "chikoo's", 'banana', "jackfruit's"]
list_with_quotes = ['"{}"'.format(x) for x in l]
query = """
select category from `unique_shelf`
where `Unique_Shelf_Names` in ({})""" .format(','.join(list_with_quotes))
This will give you an output of
select category from `unique_shelf`
where `Unique_Shelf_Names` in ("mango","apple","chikoo's","banana","jackfruit's")
Can somebody help me in converting below mentioned query in to Maximo's where clause:
select distinct workorder.wonum from workorder inner join [assignment]
On workorder.wonum=[assignment].wonum
inner join amcrew
On amcrew.amcrew=[assignment].amcrew
inner join amcrewlabor
On amcrewlabor.amcrew=amcrew.amcrew
inner join labor
On amcrewlabor.laborcode=labor.laborcode
inner join person
on labor.laborcode=person.personid where amcrewlabor.laborcode='KELLYB'
KELLYB is PERSONID used here for just reference.
If you are using a custom search query in Maximo, you can try prepending your with in (your query)
For example, if you're in Maximo's work order tracking module, the application uses select * from workorder by default. Any time you add a search filter such as work order number (wonum), then the query appends to run a query as select * from workorder where wonum = '123' if 123 is the work order number you entered.
Your where clause might look something like this:
wonum in (
select distinct workorder.wonum
from workorder
join assignment on workorder.wonum=assignment.wonum
join amcrew on amcrew.amcrew=assignment.amcrew
join amcrewlabor on amcrewlabor.amcrew=amcrew.amcrew
join labor on amcrewlabor.laborcode=labor.laborcode
join person on labor.laborcode=person.personid
where amcrewlabor.laborcode='KELLYB'
)
The SQL that is generated in Microsoft Access will not necessarily work in Maximo without some modification.
I searched a lot about sorting elements by sum of votes (in another model), like I do in SQL here :
SELECT item.* FROM item
LEFT JOIN (
SELECT
vote.item,
SUM(vote.value) AS vote.rating
FROM vote
GROUP BY vote.item
) AS res ON item.id = vote.item
ORDER BY res.rating DESC
Is there a way to do it via waterline methods ?
I think you can't do the left join with simple waterline methods, but you can use the .query method to execute your raw SQL syntax.
Sails MySQL adapter makes sum('field') conflict with sort('field'). It will generate SQL query like:
SELECT SUM(table.field) AS field FROM table ORDER BY table.field;
But I want:
SELECT SUM(table.field) AS field FROM table ORDER BY field;
It same as:
SELECT SUM(table.field) AS f FROM table ORDER BY f;
My solution is using lodash.sortBy() to process results. https://lodash.com/docs/4.16.4#sortBy
i'm using cassandra 1.2.8. i have a column family like below:
CREATE TABLE word_probability (
word text,
category text,
probability double,
PRIMARY KEY (word,category)
);
when i use query like this:
String query = "SELECT * FROM word_probability WHERE word='%s' AND category='%s';";
it works well but for some words i get this message:
name provided was not in the list of valid column labels error
every thing is ok and i don't know why i get this error :(
You're not doing anything wrong except mixing up cql with sql. Cql doesn't support % wildcards.
I tried to translate SQL "NOT IN" expression to LINQ, and I found that I should use the "Contains" option.
I have 2 tables:
ProductsGroups Products
-------------- ---------
id product_id
product_id product_name
My queries looks like this:
var innerQuery = from pg in Session.Query<ProductsGroups>
select pg.product_id;
var Query = from p in Session.Query<Products>
where !innerQuery.Contains(p.product_id)
select new {p.product_id, p.product_name};
But the sql that nHibernate generates is wrong:
select p.product_id, p.product_name
from Products p
where not (exists (select product_id
from ProductsGroups pg
where p.product_id = pg.id))
The "where" clause is not on the right field, it compares product_id to progucts group id.
Does anybody knows how can I solve it?
The solution that I found for meanwhile is to convert first query to list, and then
use this list in second query:
var innerQuery = (from pg .....).ToList();
Then, the nHibernate translates the "Contains" expression to "NOT IN", as I want:
select p.product_id, p.product_name
from Products p
where not (p.product_id in (1,2,3,4))
I am not sure, but I think you're running into a problem b/c contains determines if an element is in the collection by "using the default equality comparer." (MS documentation) I assume your productgroup mapping specifies it's Id as the Id property. So from nHibernate's perspective that is the value to use to determine equality.