where

LINQ/C#: Where & Foreach using index in a list/array

Hi, I have a list/array and need to process certain elements, but also need the index of the element in the processing. Example: List Names = john, mary, john, bob, simon Names.Where(s => s != "mary").Foreach(MyObject.setInfo(s.index, "blah") But cannot use the "index" property with lists, inversely if the names were in an Array I c...

When doing a UNION in mysql how can I do a where on the results

Hi I am doing a union over several tables. It's a little long but works! (SELECT user_id,added_date,group_id,'joined',0,0,'' FROM group_members WHERE status = 1) UNION (SELECT user_id,added_date,object_id,'made a comment',0,0,'' FROM comments WHERE object_type = 11 AND status = 1) UNION (SELECT user_id,added_date,group_id,'made the even...

How to write an "OR" within a Linq to Sql .Where()

I want to get all records WHERE (s.override == 1 OR (s.override == 2 AND s.approved == 1)) How can I do that using the .Where x.subcontracts.Where(s ==> ??) ...

What is difference between Where and Join in linq ?

hello What is difference between of these 2 queries ? they are completely equal ? from order in myDB.OrdersSet from person in myDB.PersonSet from product in myDB.ProductSet where order.Persons_Id==person.Id && order.Products_Id==product.Id select new { order.Id, person.Name, person.SurName, product.Model,UrunAdı=produc...

SQL query through an intermediate table

Given the following tables: Recipes | id | name | 1 | 'chocolate cream pie' | 2 | 'banana cream pie' | 3 | 'chocolate banana surprise' Ingredients | id | name | 1 | 'banana' | 2 | 'cream' | 3 | 'chocolate' RecipeIngredients | recipe_id | ingredient_id | 1 | 2 | 1 | 3 | 2 | 1 | 2 | ...

SQL isset and not showing blank 'cells'

Hi all, I'm using one of my MySQL database tables as an actual table, with times of the day as each column, and one column called day. You guessed it, in day it says the day of the week, and in the rest of the cells it says what is happening at that time. What I want to do is only show the cells that have value in it. In my case, I'm al...

(Mysql) How to mark different WHERE OR rows?

For example i have requested: WHERE (friend_id=? OR client_id=?) How do i know which row meets friend_id condition and which meets client_id condition? Is it possible to mark/flag rows depending of meeting condition somehow? Thanks. ...

Dynamically adding Where parameters to LinqDataSource on nullable column

I am dynamically adding a where parameter to a LinqDataSource that binds a GridView. Parameter p1 = new Parameter { Name = "Param1", Type = TypeCode.DateTime, DefaultValue = DateTime.Now.ToShortDateString() } ; MyLinqDataSource.WhereParameters.Add(p1); MyLinqDataSource.Where = "EndDate >= @Param1"; This works, but ...

Is it possible to add WHERE clauses when retrieving relationships?

In doctrine, is it possible to add a WHERE clause when fetching a property of an object that corresponds to a relationship? In terms of concept, let's say I want to retrieve only the first 3 blog posts made in the last 5 days. My "blog" object has a "posts" property which is defined as a relationship. Update... As some people are hav...

Rails 3 'where' with no conditions or 'all' lazy loading

How can I get ActiveRecord::Relation object of the model without any conditions? Of cause I can write User.where # without any args , but thats looks confusing ...

Invalid column name error in WHERE clause, column selected with CASE

I have a (rather complicated) SQL statement where I select data from lots of different tables, and to cope with a bad legacy data structure, I have a couple of custom columns that get their values based on values from other columns. I have currently solved this with CASE statements: SELECT ..., CASE channel WHEN 1 T...

WHERE aequivalent in R, multiplication conditional on another column of the same df

Dear all, i am trying to run a simple multiplication of a data.frame column with a scalar A respectively scalar B based on the value of third column (id) of the same data.frame. Somehow I have some (order,sort?) problem – so far the result is definitely wrong. Here are several tries: mydf$result = subset(mydf,myid==123,multiplyme)*0.6...

ORDER BY not working in MySQL 5.1

Hello, guys. I have a problem with sql query in php: select user, name, outlet, switch, port, vlan, mac, status from access where user like '%' and name like '%' and outlet like '%' and switch like '%' and port like '%' and vlan like '%' and mac like '%' and status like '%' order by 'user'; When r...

MySQL MATCH AGAINST query with long WHERE AND OR syntax?

The following query is not working the way I expect: SELECT DISTINCT * FROM mytable WHERE MATCH (StrNum, StrName, StrType, TownName, Zip) AGAINST ('elm') AND Color = 'RED' OR Color = 'WHITE' OR Color = 'BLUE' This is returning more results than I expect - it's not limiting my results to those on 'elm'. If I remove the last line (A...

SQL INNER JOIN question

Hi, I'm creating a query that will display information for a record which is derived from 8 tables. The developer who originally wrote the query used a combination of 'where this equals this' AND 'this equals this' to create the joins. I have since changed the query to use INNER JOINS. I wondered if my approach was better than utilisin...

Linq where clause problem

I thought I'd seen somewhere a while back an example of where clause which called a function that gave a bool result ,and I can't find it again so I'll outline my problem. I have a collection Dictionary< string, KeyValuePair < int, int >> in which I want to have a query for the string key. On the surface that is simple but unfo...

Create fully dynamic where clause with expression tree and execute on IQueryable

At point (3) in my code I have defined a query called query1 in which I defined a .Where lambda expression. This query is in some way dynamic but still contains static elements, it always refers to the Type Employee and its (int) property ClientID. Now I very much like to make the refering to the type and its property dynamic, based on...

How to write "WHERE foo = 'bar' OR foo = 'baz' OR ..." without repeating "foo" each time

I'm new to MySQL and was wondering; instead of doing SELECT fields FROM table WHERE name="tim" OR name="bob" OR name="nancy" OR name="john" If I could do something like SELECT fields FROM table WHERE (name="tim" OR "bob" OR "nancy" OR "john") ...

SQL Sever: in...case...in WHERE clause

Hi, I need to code up a query for something like this: Select [something] Where condition in case when (if another_condition = A and 3rd Condition = B) then (C,D) when (if another_condition = N and 3rd Condition = E) then (F,G) else (J,K) end essentially, what I want is if A and B are met, condition could be set to either C or D, if N...

redirecting output of 'where' in dbx

I'm trying to get the call stacks leading to a function, func, each time it gets invoked in my executable, and I don't mind if the way to get this is slow or inefficient, so long as it's automated (because 'func' gets hit thousands of times). I have access to dbx, so I thought I could do something like this: (dbx) { when in func { wher...