in-subquery

LINQ subquery IN

余生颓废 提交于 2019-11-30 13:58:02
I'm a newbie with the IQueryable, lambda expressions, and LINQ in general. I would like to put a subquery in a where clause like this : Sample code : SELECT * FROM CLIENT c WHERE c.ETAT IN ( SELECT DDV_COLUMN_VAL FROM DATA_DICT_VAL WHERE TBI_TABLE_NAME = 'CLIENT' AND DD_COLUMN_NAME = 'STATUS' AND DDV_COLUMN_VAL_LANG_DSC_1 LIKE ('ac%')) How do I translate this in LINQ ? var innerquery = from x in context.DataDictVal where x.TbiTableName == myTableNameVariable && x.DdColumnName == "Status" && x.DdbColumnValLangDsc1.StartsWith("ac") select x.DdvColumnVal; var query = from c in context.Client

Oracle subquery funniness

老子叫甜甜 提交于 2019-11-28 14:07:29
Imagine a query SELECT Col_A FROM TABLE_A WHERE Col_A IN (SELECT Col_A FROM TABLE_B) Except, TABLE_B does not have a Col_A column; Only TABLE_A has it. I tried this in Oracle 12 and I'm not sure how far back in versions it goes but it looks like is returns a valid result of showing all of Col_A data from TABLE_A. As a developer I'm expecting something like this to throw an error since the inner query does not even access the TABLE_A again so to speak. Can someone explain why or where we would use a query situation like the one above because I almost feel like it should be a bug in the system.

MySQL DELETE FROM with subquery as condition

假如想象 提交于 2019-11-26 14:13:02
I am trying to do a query like this: DELETE FROM term_hierarchy AS th WHERE th.parent = 1015 AND th.tid IN ( SELECT DISTINCT(th1.tid) FROM term_hierarchy AS th1 INNER JOIN term_hierarchy AS th2 ON (th1.tid = th2.tid AND th2.parent != 1015) WHERE th1.parent = 1015 ); As you can probably tell, I want to delete the parent relation to 1015 if the same tid has other parents. However, that yields me a syntax error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS th WHERE th.parent = 1015 AND th.tid IN ( SELECT

JPA 2.0, Criteria API, Subqueries, In Expressions

那年仲夏 提交于 2019-11-26 00:59:05
问题 I have tried to write a query statement with a subquery and an IN expression for many times. But I have never succeeded. I always get the exception, \" Syntax error near keyword \'IN\' \", the query statement was build like this, SELECT t0.ID, t0.NAME FROM EMPLOYEE t0 WHERE IN (SELECT ? FROM PROJECT t2, EMPLOYEE t1 WHERE ((t2.NAME = ?) AND (t1.ID = t2.project))) I know the word before \'IN\' lose. Have you ever written such a query? Any suggestion? 回答1: Below is the pseudo-code for using sub

JPA 2.0, Criteria API, Subqueries, In Expressions

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-25 21:34:57
I have tried to write a query statement with a subquery and an IN expression for many times. But I have never succeeded. I always get the exception, " Syntax error near keyword 'IN' ", the query statement was build like this, SELECT t0.ID, t0.NAME FROM EMPLOYEE t0 WHERE IN (SELECT ? FROM PROJECT t2, EMPLOYEE t1 WHERE ((t2.NAME = ?) AND (t1.ID = t2.project))) I know the word before 'IN' lose. Have you ever written such a query? Any suggestion? Below is the pseudo-code for using sub-query using Criteria API. CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery