How to query a record across the database with id - orientdb

I have a custom unique index called "id" in all my vertices and edges. I want something like
Select * from * where id='1234'
Is this even possible?

Select * from V where id='1234'
worked like a charm!

Related

Is it possible to adjust an array in PostgreSQL to fit with an IN operator?

Something like:
SELECT * FROM table WHERE something IN ('{"val1","val2"}'::text[]);
I tried it with array_to_string().
SELECT * FROM table WHERE something IN (array_to_string('{"val1","val2"}'::text[]));
But I guess that makes it to this:
SELECT * FROM table WHERE something IN ('val1,val2'); --one single string
I guess the single values must also be surrounded with apostrophes.
Is that possible somehow, or can it be solved in a completely different way?
Use the ANY operator:
SELECT *
FROM table
WHERE something = ANY ('{"val1","val2"}'::text[]);
You are looking for ANY:
SELECT *
FROM example
WHERE something = ANY('{"val1","val2"}'::text[]);
But if you insist on using IN, you can achieve the same with UNNEST:
SELECT *
FROM example
WHERE something IN (SELECT UNNEST('{"val1","val2"}'::text[]));
(online demo)

What is the equivalent of SQL subquery in MongoDB?

Is there a way to combine two finds in MongoDB similar to the SQL subqueries?
What would be the equivalent of something like:
SELECT * FROM TABLE1 WHERE name = (SELECT name FROM TABLE2 WHERE surname = 'Smith');
I need to get an uuid from one collection searching by email and then use it to filter in another. I would like if possible to make it with just one find instead of get the uuid, store it in a variable and then search second time using the variable...
Here are the two that I want combined somehow:
db.getCollection('person').find({email:'perry.goodwin#yahoo.com'}).sort({_id:-1});
db.getCollection('case').find({applicantUuid:'4a17e96c-caf9-4d78-a853-73e190005c63'});

how do I perform a case-insensitive search in a Postgres 9.4 JSONB column?

i'm using this query to look for data in a table where profile is a JSONB column
and it works but only if the name is exactly that
SELECT * FROM "users" WHERE "profile" #> '{"name":"Super User"}'
is it possible to have more flexibility like case insensitivity, wildcards and so on ?
Something like "Super%" or "super user"
I found the solution to my problem:
SELECT * FROM "users" WHERE (profile #>> '{name}') ILIKE 'super %'
I don't know if this is performing well enough but it works.
Probably it's wise to add an index to it.

Using SphinxQL with SphinxSE

Can I actually use sphinxQL with SphinxSE plugin?
Like this:
SELECT * FROM t1 WHERE query='SELECT id FROM products GROUP BY region, price';
Nope. Two completely different ways of accessing sphinx.
SphinxSE under the hood uses the SphinxAPI.
SELECT * FROM t1 WHERE query=';select=id;index=products;groupby=attr:region,price';
Although I dont know if the multiple attribute group by will work.

Combine dynamic columns with select query

I am using a PostgreSQL database. I have one select query:
select userid, name, age from tbluser;
Now there is another table, tblcalculatedtax, which is generated on the fly and their column names are not predefined, the only mapping between that table and this table is userid. I want to get records after joining two tables. How can I get that?
Simpler:
SELECT *
FROM tbluser
JOIN tblcalculatedtax USING (userid)
Details in the fine manual about SELECT.
Your need SQL Joins. Here's a W3Schools tutorial: http://www.w3schools.com/sql/sql_join.asp
To quickly answer your question, though:
SELECT * FROM tbluser
INNER JOIN tblcalculatedtax
ON tbluser.userid=tblcalculatedtext.userid
The * selects all the columns, so you don't need to know their names. Of course, I'm not sure what use a column is to you if you don't know it's name: do you know what data it contains?