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
25
votes
3 answers
T-SQL: Where xxx IN temporary table
I have a temp table and want to check in a where clause wether a certain id/string is contained in the temp table.
Select...
WHERE MyId IN MyTempTable
I get a general error in MS SQL Management studio.
is the "In" operator not suited for temp…

Elisabeth
- 20,496
- 52
- 200
- 321
25
votes
5 answers
MySQL user-defined variable in WHERE clause
I want to know if there is a way to use a user-defined variable in WHERE clause, as in this example:
SELECT id, location, @id := 10 FROM songs WHERE id = @id
This query runs with no errors but doesn't work as expected.

Paulo Freitas
- 13,194
- 14
- 74
- 96
25
votes
2 answers
Explain JOIN vs. LEFT JOIN and WHERE condition performance suggestion in more detail
In this candidate answer it is asserted that JOIN is better than LEFT JOIN under some circumstances involving some WHERE clauses because it does not confuse the query planner and is not "pointless". The assertion/assumption is that it should be…

Dwayne Towell
- 8,154
- 4
- 36
- 49
25
votes
2 answers
mysqldump with WHERE id IN (SELECT ...) yields table "was not locked" error
I have 2 databases, with ~100,000 rows missing from the table field_collection_item from db1, which I'd like to repair by exporting from db2.
My plan to accomplish this was to:
identify the missing items by item_id in db2, exporting the list of…

DanH
- 5,498
- 4
- 49
- 72
25
votes
1 answer
Haskell - defining a function with guards inside a 'where'
I'm just starting out at teaching myself Haskell. This code is supposed to do prime factorisation:
divides :: Integer -> Integer -> Bool
divides small big = (big `mod` small == 0)
lowestDivisor :: Integer -> Integer
lowestDivisor n =…

Benjamin Hodgson
- 42,952
- 15
- 108
- 157
24
votes
6 answers
Can the "IN" operator use LIKE-wildcards (%) in Oracle?
I have searched this question, and found an answer in MySQL but this is one of those incidents where the statement fails to cross over into Oracle.
Can I use wildcards in "IN" MySQL statement?
pretty much sums up my question and what I would like to…

Matt
- 275
- 1
- 3
- 10
24
votes
5 answers
How do you do a Rails 3 select IN using where clauses
I am using Rails 3 and I need to do a select where the primary key of the records is IN a resulting previous select. You can do this easily using straight SQL using an IN. Here is the obviously incorrect way I have done what I need. What's the…

Bob Benedict
- 467
- 1
- 4
- 10
24
votes
6 answers
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 |…

Bryan Ash
- 4,385
- 3
- 41
- 57
24
votes
2 answers
Convert string to int inside WHERE clause of SQLITE statment
I want to achieve this:
SELECT * FROM linkledger WHERE toInt(reputation) > 100;
but the function toInt doesnt exist? Is there one?
I found this now but not working, which implies i have a more fundemental problem. BECAUSE THIS IS CORRECT
SELECT *…

Banned_User
- 973
- 2
- 9
- 17
23
votes
1 answer
mysql fix Using where;
My SQL Query:
SELECT *
FROM updates_cats
WHERE uid =118697835834
ORDER BY created_date ASC
Current Indexes:
index1(uid, created_date)
EXPLAIN EXTENDED result:
1 SIMPLE updates_cats ref index1 index1 8 const 2 100.00 Using where
How can i fix the…

stergosz
- 5,754
- 13
- 62
- 133
23
votes
2 answers
Postgres - WHERE clause on whether values contain a certain string
If I want to retrieve all entries such that the column foo value contains a string 'bar', is there a simple way to do this in SQL, or Postgresql?
Something like ' WHERE foo = "bar"' but instead of = it would be something like ' WHERE foo CONTAINS…

tscizzle
- 11,191
- 15
- 54
- 88
23
votes
5 answers
Ignore Hibernate @Where annotation
I have an Entity which has an association to another Entity annotated with @Where, like so
public class EntityA {
@OneToMany
@Where(...)
private List entityBList;
}
Recently the inevitable has happened, I need to load…

Zecrates
- 2,952
- 6
- 33
- 50
23
votes
3 answers
SQL Query with Join, Count and Where
I have 2 tables and am trying to do one query to save myself some work.
Table 1: id, category id, colour
Table 2: category id, category name
I want to join them so that I get id, category id, category name, colour
Then I want to limit it so that…

Watters
- 368
- 1
- 2
- 9
23
votes
5 answers
CASE in WHERE, SQL Server
I'm doing some search, where users are choosing in dropdown some clauses. When they leave some box empty, I want query to ignore clause. I know CASE, and best I thought of is that if I pass 0 to parameter in stored procedure, it ignores that…

el ninho
- 4,183
- 15
- 56
- 77
22
votes
4 answers
Why is it so uncommon to use type signatures in where clauses?
Does it help the compiler to optimise, or is it just surplus work to add additional type signatures? For example, one often sees:
foo :: a -> b
foo x = bar x
where bar x = undefined
Rather than:
foo :: a -> b
foo x = bar x
where bar ::…

epsilonhalbe
- 15,637
- 5
- 46
- 74