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
49
votes
8 answers
WHERE clause before INNER JOIN
If I have
SELECT * FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.id = t2.id
WHERE t1.user='bob';
Does the WHERE clause run after the two tables are JOINED?
How do I make it so it runs prior to the JOIN?

user1124535
- 765
- 3
- 9
- 15
48
votes
3 answers
SQL JOIN where to place the WHERE condition?
I have two following examples.
1. Example (WHERE)
SELECT 1
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id
WHERE t2.field = true
2. Example (JOIN AND)
SELECT 1
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id AND t2.field = true
What is the…

Aley
- 8,540
- 7
- 43
- 56
47
votes
13 answers
why would you use WHERE 1=0 statement in SQL?
I saw a query run in a log file on an application. and it contained a query like:
SELECT ID FROM CUST_ATTR49 WHERE 1=0
what is the use of such a query that is bound to return nothing?

MozenRath
- 9,652
- 13
- 61
- 104
46
votes
5 answers
SQL Not Like Statement not working
I have the following code within a stored procedure.
WHERE
WPP.ACCEPTED = 1 AND
WPI.EMAIL LIKE '%@MATH.UCLA.EDU%' AND
(WPP.SPEAKER = 0 OR
WPP.SPEAKER IS NULL) AND
WPP.COMMENT NOT LIKE '%CORE%' AND
WPP.PROGRAMCODE =…

mattgcon
- 4,768
- 19
- 69
- 117
44
votes
11 answers
DISTINCT clause with WHERE
How can I use the DISTINCT clause with WHERE? For example:
SELECT * FROM table WHERE DISTINCT email; -- email is a column name
I want to select all columns from a table with distinct email addresses.

Mohit
- 1,204
- 2
- 13
- 19
43
votes
5 answers
C# FindAll VS Where Speed
Anyone know any speed differences between Where and FindAll on List. I know Where is part of IEnumerable and FindAll is part of List, I'm just curious what's faster.

Dested
- 6,294
- 12
- 51
- 73
41
votes
5 answers
Which performs first WHERE clause or JOIN clause
Which clause performs first in a SELECT statement?
I have a doubt in select query on this basis.
consider the below example
SELECT *
FROM #temp A
INNER JOIN #temp B ON A.id = B.id
INNER JOIN #temp C ON B.id = C.id
WHERE A.Name = 'Acb' AND…

MohanKrishnaRS
- 423
- 1
- 4
- 14
41
votes
1 answer
Swift "where" Array Extensions
As of Swift 2.0 it seems we can get closer to extensions of generic types applicable to predicated situations.
Although we still can't do this:
protocol Idable {
var id : String { get }
}
extension Array where T : Idable {
...
}
...we can…

yo.ian.g
- 1,354
- 2
- 14
- 21
40
votes
3 answers
Use a calculated column in a where clause
I'm trying to use a calculated column in a where clause.
I've been trying everything from CROSS APPLY, to sub-query select but it does not give me anything near what I need.
My query so far:
SELECT p.Code, c.AccountNumber, Sales = (SUM(p.UnitPrice)…

JadedEric
- 1,943
- 2
- 26
- 49
40
votes
6 answers
SQL Server : check if variable is Empty or NULL for WHERE clause
When searching for a list of products, the @SearchType parameter is optional. If @SearchType is empty or NULL then it should return all products and not use the WHERE clause. Otherwise, if it passed Equipment it would then use that instead.
ALTER…

User970008
- 1,135
- 3
- 20
- 49
39
votes
4 answers
How can you turn an index array into a mask array in Numpy?
Is it possible to convert an array of indices to an array of ones and zeros, given the range?
i.e. [2,3] -> [0, 0, 1, 1, 0], in range of 5
I'm trying to automate something like this:
>>> index_array = np.arange(200,300)
array([200, 201, ... ,…

Efreeto
- 2,132
- 1
- 24
- 25
38
votes
5 answers
How do I append a 'where' clause using VB.NET and LINQ?
I am pretty new to VB.NET and am having a bit of trouble here with something I thought should be simple.
Keeping it simple, let's say I have a Document table with "Name" that I want to search on (in reality there are several other tables, joins,…

sugarcrum
- 1,001
- 4
- 13
- 19
38
votes
2 answers
Eloquent where condition based on a "belongs to" relationship
Let's say I have the following model:
class Movie extends Eloquent
{
public function director()
{
return $this->belongsTo('Director');
}
}
Now I'd like fetch movies using a where condition that's based on a column from the…

Lior
- 5,454
- 8
- 30
- 38
37
votes
1 answer
How to check if Fortran array contains value?
I've seen this asked for other languages, but having just found out how nicely Fortran can handle arrays, I thought there might be an easy way to do this without loops.
Currently I'm searching over a 3D array looking at 'nearest neighbours' to see…

AncientSwordRage
- 7,086
- 19
- 90
- 173
37
votes
5 answers
Can you use "where" to require an attribute in c#?
I want to make a generic class that accepts only serializable classes, can it be done with the where constraint?
The concept I'm looking for is this:
public class MyClass where T : //[is serializable/has the serializable attribute]

juan
- 80,295
- 52
- 162
- 195