where-clause

How would I improve this 7 line Linq Query that acts as a Specification?

China☆狼群 提交于 2019-12-05 22:00:36
BigQuery at the top gets a set of Products and nested related tables. Then, I apply filtering in a poor attempt at a specification pattern. This is the filter code. There are three tables in the query, and I want to filter the top query by the value nested in the bottom query. Like I said, this currently produces the results we want. However, the .Contains() produces a SQL WHERE EXISTS() clause for each. We really only need one, but I don't know how to get the inner ID to compare with the outer ID. from p in bigQuery // Root table where ( from pp in p.LPP // Level 1 nested table where (from pv

Evaluation of multiples 'IN' Expressions in 'WHERE' clauses in mysql

有些话、适合烂在心里 提交于 2019-12-05 21:35:16
问题 Updating by @Cesar 's request. Hope I understood what you want, if not, please revert. Quassnoi. If I make an SQL query like this: SELECT * FROM TABLE_NAME WHERE b IN (2, 7) AND c IN (3, 9) , can I assume that MySQL will match only pairs from elements with same number in each list? That is, (2, 3) , (7, 9) , ...? For example, suppose we have a table like this: +----------+----------+----------+ | PK | b | c | +----------+----------+----------+ | 1 | 2 | 3 | +----------+----------+----------+

How can I prevent the LinqDataSource Where clause from resetting on postback?

核能气质少年 提交于 2019-12-05 19:18:46
I'm trying to set the where clause on a LinqDataSource object bound to a GridView programmatically on a button click, but when the GridView rebinds data (for instance, when the user sorts) the Where clause resets back to the empty string. Is there a way to prevent this, or is there a better way to filter my results? justin.lovell Perhaps you just add a ViewState property into your page/user control and then retrieve it on all post back? public string MyLinqSourceWhere { get { return (string)this.ViewState["MyLinqSourceWhere"]; } set { this.ViewState["MyLinqSourceWhere"] = value; } } public

MySQL update query with WHERE clause and INNER JOIN not working

时光总嘲笑我的痴心妄想 提交于 2019-12-05 14:09:07
Can't seem to reach the next step in my update query. I'm able to successfully view columns related to the select no problem: SELECT sales_flat_order_grid.entity_id,sales_flat_order_grid.increment_id,sales_flat_order.coupon_code FROM sales_flat_order_grid INNER JOIN sales_flat_order ON sales_flat_order_grid.entity_id = sales_flat_order.entity_id WHERE sales_flat_order_grid.increment_id = "12345678"; This shows 3 columns all where related to the correct increment_id. The next step is to update the sales_flat_order.coupon_code field. Here is my attempt: UPDATE sales_flat_order INNER JOIN sales

using mysql variable to hold comma separated value to be used for where in clause

大憨熊 提交于 2019-12-05 06:03:05
I have to run a query like this (query 1) - select something from sometable where someId in (1,2,3) I would like to keep a variable for the IDs part, like this (query 2) - set @myIds = "1,2,3"; select something from sometable where someId in (@myIds); But this does not give the expected result (gives an empty result set), and no query error as well. I checked that if I wrap the comma separated IDs inside quotes, the query results an empty result set (query 3) - select something from sometable where someId in ("1,2,3"); I guess when I am using variable @myIds like I showed above (query 2), it

Multi-Column Name Search MySQL

非 Y 不嫁゛ 提交于 2019-12-05 04:17:13
问题 I am currently working on a live search and I need to be able to find parts of a name in two columns (we need to separate first and last name). I personally would like to keep the command short, however the only way I have been able to get this to work is: User Searches For John Doe Generated SQL Query SELECT * FROM users WHERE (first_name LIKE '%john%' OR last_name LIKE '%john%') AND (last_name LIKE '%doe%' OR last_name LIKE '%doe%'); The search field is one box so I do some simple

LINQ results when there are no matches?

社会主义新天地 提交于 2019-12-05 04:06:32
What exactly does a LINQ function return when there are no matches? Take the Where method, for example: var numbers = Enumerable.Range(1, 10); var results = numbers.Where(n => n == 50); What would be in results at this point? results itself is just a query. Until you start to iterate through it (either explicitly or via a call like Count() ), nothing has checked whether there are any results or not. It's only when you enumerate it that anything will happen. So you could do: foreach (int x in results) { Console.WriteLine("This won't happen"); } Or: Console.WriteLine(results.Any()); // Will

Will Postgres push down a WHERE clause into a VIEW with a Window Function (Aggregate)?

*爱你&永不变心* 提交于 2019-12-05 03:03:20
The docs for Pg's Window function say : The rows considered by a window function are those of the "virtual table" produced by the query's FROM clause as filtered by its WHERE, GROUP BY, and HAVING clauses if any. For example, a row removed because it does not meet the WHERE condition is not seen by any window function. A query can contain multiple window functions that slice up the data in different ways by means of different OVER clauses, but they all act on the same collection of rows defined by this virtual table. However, I'm not seeing this. It seems to me like the Select Filter is very

LINQ WHERE with OR

橙三吉。 提交于 2019-12-05 00:55:48
I use LINQ to create my where clause like so: var query = from x in context.Xs select x; if (y == ...) { query = query.Where(x => x.Y == 1); } I have bunch of these "if .... where" statements. The issue I have is that all of those wheres join where clauses using AND but I need all my where clauses to use OR. Is there an easy way to port this code into where OR code? Or even what is the easiest way to do this with OR? Thanks. PredicateBuilder is the perfect solution for your problem. It allows you to keep adding individual "AND" as well as "OR" statements together. You could do something like:

Cassandra - WHERE clause with non primary key disadvantages

孤街浪徒 提交于 2019-12-05 00:50:39
I am new to cassandra and I am using it for analytics tasks (good indexing needed ). I read in this post (and others): cassandra, select via a non primary key that I can't query my DB with a non-primary key columns with WHERE clause . To do so, it seems that there is 3 possibilities (ALL with major disadvantages): Create a secondary index (not recommended for performance issues). Create a new table (I don't want redundant data even if it's ok with cassandra). Put the column I want to query by within the primary key and in this case I need to define all the parts of the primary key in my WHERE