A syntactic form in functional languages used to bind a value to a name in a local scope. Similar, but not identical to, let.
Questions tagged [where-clause]
9069 questions
19
votes
5 answers
Filter based on an aliased column name
I'm using SqlServer 2005 and I have a column that I named.
The query is something like:
SELECT id, CASE WHEN END AS myAlias
FROM myTable
WHERE myAlias IS NOT NULL
However, this gives me the error:
"Invalid column…

Nathan Koop
- 24,803
- 25
- 90
- 125
19
votes
3 answers
MYSQL Select rows where date is older than datetime
I am coding a status item for a website and need to load statuses older than a variable that contains a datetime.
So the database has a field called added date which is a datetime field and I have a string in datetime format and i want to select all…

André Figueira
- 6,048
- 14
- 48
- 62
18
votes
2 answers
What is the Big O of linq .where?
I am doing some comparisons about where to filter out items from a list. I am unsure of doing it directly which would be O(n), or using .Where(). I made a simple example to test .Where() on a simple data set. There are n=100 items, and when I run…

Travis J
- 81,153
- 41
- 202
- 273
18
votes
6 answers
Execution order of conditions in SQL 'where' clause
I have a set of conditions in my where clause like
WHERE
d.attribute3 = 'abcd*'
AND x.STATUS != 'P'
AND x.STATUS != 'J'
AND x.STATUS != 'X'
AND x.STATUS != 'S'
AND x.STATUS != 'D'
AND CURRENT_TIMESTAMP - 1 < x.CREATION_TIMESTAMP
Which of…

sarego
- 2,957
- 6
- 28
- 39
18
votes
5 answers
In SQL how to compare date values?
Using MySQL syntax and having a table with a row like:
mydate DATETIME NULL,
Is there a way to do something like:
... WHERE mydate<='2008-11-25';
I'm trying but not really getting it to work.

fmsf
- 36,317
- 49
- 147
- 195
17
votes
3 answers
Is something in the 'where' clause in Haskell only calculated once?
When I have the following code:
func n = m ++ [1] ++ m ++ [0] ++ m
where m = func2 n
How many times is the func2 function called? Only once, in the where clause? Or is it just calculated again every time I use m?

Thomas
- 261
- 1
- 7
17
votes
2 answers
Check if datetime is in current date
I am using SQLServer 2008. I have a table X with field Y that is a datetime format. In the WHERE statement of my query I only want to keep the rows where the date of field Y equals the current date.
I have searched the internet but couldnt find an…

Anonymoose
- 2,389
- 6
- 36
- 69
17
votes
3 answers
Where to place and configure IoC container in a WPF application?
I am working on a middle sized WPF application (MVVM) that should be extensible and maintainable in the future. Thus I decided to use an IoC container (Unity in this case) to keep things flexible.
However I am not sure where to place and configure…

matori82
- 3,669
- 9
- 42
- 64
17
votes
1 answer
PostgreSQL Query WHERE date is greater than 3 years old
I have a table that contains 4 dates:
CREATE TABLE dates (
date date
);
11-mar-2008
25-now-2007
18-apr-2012
20-apr-2012
I need a query that returns all dates that are older than three-years-old. That should be the first 2…

Danny Calladine
- 321
- 1
- 2
- 13
16
votes
3 answers
Postgres array lookup in WHERE clause
I have a query:
SELECT bar, (SELECT name FROM names WHERE value = bar) as name
FROM foobar WHERE foo = 1 and bar = ANY (1,2,3)
My problem is, when there is no row containing bar = 3 (or whatever other value is requested) in table foobar, no rows…

Alex Tokarev
- 4,821
- 1
- 20
- 30
16
votes
4 answers
Using np.where but maintaining exisitng values if condition is False
I like np.where, but have never fully got to grip with it.
I have a dataframe lets say it looks like this:
import pandas as pd
import numpy as np
from numpy import nan as NA
DF = pd.DataFrame({'a' : [ 3, 0, 1, 0, 1, 14, 2, 0, 0, 0, 0],
…

Woody Pride
- 13,539
- 9
- 48
- 62
16
votes
5 answers
T-SQL Where Clause Case Statement Optimization (optional parameters to StoredProc)
I've been battling this one for a while now. I have a stored proc that takes in 3 parameters that are used to filter. If a specific value is passed in, I want to filter on that. If -1 is passed in, give me all.
I've tried it the following two…

IronicMuffin
- 4,182
- 12
- 47
- 90
16
votes
7 answers
MySQL direct INSERT INTO with WHERE clause
I tried googling for this issue but only find how to do it using two tables, as follows,
INSERT INTO tbl_member
SELECT Field1,Field2,Field3,...
FROM temp_table
WHERE NOT EXISTS(SELECT *
FROM tbl_member
WHERE…

Hasitha Shan
- 2,900
- 6
- 42
- 83
16
votes
4 answers
Scala equivalent to Haskell's where-clauses?
Is it possible to use something similar to where-clauses in Scala? Maybe there is some trick I didn't think of?
Edit:
Thanks for all your answers, they are very much appreciated. To sum up:
Local vars, vals and defs can be used to achieve almost the…

Kim Stebel
- 41,826
- 12
- 125
- 142
16
votes
3 answers
Rails where clause over two tables
I have the following model in rails application
category => company => store
Store has a belongs_to company and company has a belongs_to category relationship.
now i want to use a where method on a store object to retrieve all stores within the…

Martin
- 790
- 2
- 9
- 24