where-in

SQL IN equivalent in CAML

我怕爱的太早我们不能终老 提交于 2019-11-28 20:47:06
Is there a "nice" way to create a CAML query for SharePoint that does something like this? SELECT * FROM table WHERE Id IN (3, 12, ...) Or am I stuck with a nightmare of nested <Or> nodes? EDIT: This was my solution to generate the <Or> nodes. /// Simulates a SQL 'Where In' clause in CAML /// </summary> /// <param name="columnType">Specifies the data type for the value contained by the field.</param> /// <returns>Nested 'Or' elements portion of CAML query</returns> public static string CamlIn<T>(string internalFieldName, string columnType, T[] values) { XDocument doc = new XDocument();

Python/psycopg2 WHERE IN statement

安稳与你 提交于 2019-11-28 18:32:00
What is the correct method to have the list (countryList) be available via %s in the SQL statement? # using psycopg2 countryList=['UK','France'] sql='SELECT * from countries WHERE country IN (%s)' data=[countryList] cur.execute(sql,data) As it is now, it errors out after trying to run "WHERE country in (ARRAY[...])". Is there a way to do this other than through string manipulation? Thanks For the IN operator, you want a tuple instead of list , and remove parentheses from the SQL string. # using psycopg2 data=('UK','France') sql='SELECT * from countries WHERE country IN %s' cur.execute(sql,

MySQL multiple columns in IN clause

人盡茶涼 提交于 2019-11-28 02:47:29
问题 I have a database with four columns corresponding to the geographical coordinates x,y for the start and end position. The columns are: x0 y0 x1 y1 I have an index for these four columns with the sequence x0, y0, x1, y1. I have a list of about a hundred combination of geographical pairs. How would I go about querying this data efficiently? I would like to do something like this as suggested on this SO answer but it only works for Oracle database, not MySQL: SELECT * FROM my_table WHERE (x0, y0

Python/psycopg2 WHERE IN statement

陌路散爱 提交于 2019-11-27 20:16:23
问题 What is the correct method to have the list (countryList) be available via %s in the SQL statement? # using psycopg2 countryList=['UK','France'] sql='SELECT * from countries WHERE country IN (%s)' data=[countryList] cur.execute(sql,data) As it is now, it errors out after trying to run "WHERE country in (ARRAY[...])". Is there a way to do this other than through string manipulation? Thanks 回答1: For the IN operator, you want a tuple instead of list, and remove parentheses from the SQL string. #

SELECT from table with Varying IN list in WHERE clause

为君一笑 提交于 2019-11-27 15:11:19
I am facing a issue in project I am working on, I can not give you actual code but I have created a executable sample code as below Here temp and temp_id are two tables temp table contains comma separated list of ids which is VARCHAR2 temp_id table contains actual ids which is NUMBER I want to search rows from temp_id table by getting ids from comma separated list of ids from temp table //DDLs to create table CREATE TABLE temp(ids VARCHAR2(4000)); CREATE TABLE temp_id(data_id NUMBER); //DMLs to populate test data INSERT INTO temp VALUES('1, 2, 3'); INSERT INTO temp_id VALUES(1); INSERT INTO

LINQ to Entities - where..in clause with multiple columns

浪尽此生 提交于 2019-11-27 14:45:29
问题 I'm trying to query data of the form with LINQ-to-EF: class Location { string Country; string City; string Address; … } by looking up a location by the tuple (Country, City, Address). I tried var keys = new[] { new {Country=…, City=…, Address=…}, … } var result = from loc in Location where keys.Contains(new { Country=loc.Country, City=loc.City, Address=loc.Address } but LINQ doesn't want to accept an anonymous type (which I understand is the way to express tuples in LINQ) as the parameter to

SQL IN equivalent in CAML

穿精又带淫゛_ 提交于 2019-11-27 13:10:41
问题 Is there a "nice" way to create a CAML query for SharePoint that does something like this? SELECT * FROM table WHERE Id IN (3, 12, ...) Or am I stuck with a nightmare of nested <Or> nodes? EDIT: This was my solution to generate the <Or> nodes. /// Simulates a SQL 'Where In' clause in CAML /// </summary> /// <param name="columnType">Specifies the data type for the value contained by the field.</param> /// <returns>Nested 'Or' elements portion of CAML query</returns> public static string CamlIn

MySQL - SELECT WHERE field IN (subquery) - Extremely slow why?

北城以北 提交于 2019-11-26 19:20:17
I've got a couple of duplicates in a database that I want to inspect, so what I did to see which are duplicates, I did this: SELECT relevant_field FROM some_table GROUP BY relevant_field HAVING COUNT(*) > 1 This way, I will get all rows with relevant_field occuring more than once. This query takes milliseconds to execute. Now, I wanted to inspect each of the duplicates, so I thought I could SELECT each row in some_table with a relevant_field in the above query, so I did like this: SELECT * FROM some_table WHERE relevant_field IN ( SELECT relevant_field FROM some_table GROUP BY relevant_field

SELECT from table with Varying IN list in WHERE clause

我的未来我决定 提交于 2019-11-26 11:33:23
问题 I am facing a issue in project I am working on, I can not give you actual code but I have created a executable sample code as below Here temp and temp_id are two tables temp table contains comma separated list of ids which is VARCHAR2 temp_id table contains actual ids which is NUMBER I want to search rows from temp_id table by getting ids from comma separated list of ids from temp table //DDLs to create table CREATE TABLE temp(ids VARCHAR2(4000)); CREATE TABLE temp_id(data_id NUMBER); //DMLs

How to do this in Laravel, subquery where in

廉价感情. 提交于 2019-11-26 07:27:09
How can I make this query in Laravel: SELECT `p`.`id`, `p`.`name`, `p`.`img`, `p`.`safe_name`, `p`.`sku`, `p`.`productstatusid` FROM `products` p WHERE `p`.`id` IN ( SELECT `product_id` FROM `product_category` WHERE `category_id` IN ('223', '15') ) AND `p`.`active`=1 I could also do this with a join, but I need this format for performance. lukaserat Consider this code: Products::whereIn('id', function($query){ $query->select('paper_type_id') ->from(with(new ProductCategory)->getTable()) ->whereIn('category_id', ['223', '15']) ->where('active', 1); })->get(); drewjoh Have a look at the advanced