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
14
votes
8 answers
How to add a where clause in a MySQL Insert statement?
This doesn't work:
INSERT INTO users (username, password) VALUES ("Jack","123") WHERE id='1';
Any ideas how to narrow insertion to a particular row by id?

Zack
- 151
- 1
- 1
- 4
14
votes
2 answers
Doctrine: Multiple (whereIn OR whereIn) query?
I'm having trouble crafting a fairly simple query with Doctrine...
I have two arrays ($countries, $cities) and I need to check whether database record values would match any inside either. I'm looking for something like:
->whereIn('country', 'city',…

Tom
- 30,090
- 27
- 90
- 124
14
votes
6 answers
How to conditionally filter on a column in a WHERE clause?
OK, the umpteenth conditional column question:
I'm writing a stored proc that takes an input parameter that's mapped to one of several flag columns. What's the best way to filter on the requested column? I'm currently on SQL2000, but about to move…

Val
- 2,291
- 7
- 34
- 63
13
votes
2 answers
Why does List not implement IOrderedEnumerable?
I would like to work with ordered enumerables, and use interfaces as return types rather than the concrete types. I need to return an ordered set of objects. But, when using an IList implementation I can not return IOrderedEnumerable, as…

Marcel
- 15,039
- 20
- 92
- 150
13
votes
7 answers
Why would a sql query have "where 1 = 1"
I was going through a few queries I am maintaining, and a programmer had put in the queries "where 1=1" to me that always seems to evaluate to true.
Are there benefits to this?
Duplicate: Why would someone use WHERE 1=1 AND in a SQL clause?
That…

Jeremy Boyd
- 5,245
- 7
- 33
- 57
13
votes
4 answers
LINQ- Max in where condition
I have a class TaskWeekUI with this definition:
public class TaskWeekUI {
public Guid TaskWeekId { get; set; }
public Guid TaskId { get; set; }
public Guid WeekId { get; set; }
public DateTime EndDate { get; set; }
public string…

Shayan
- 402
- 1
- 4
- 18
13
votes
4 answers
Aggregate functions in WHERE clause in SQLite
Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this:
SELECT * FROM table ORDER BY timestamp DESC LIMIT 1
But I'd much…

Kyle Cronin
- 77,653
- 43
- 148
- 164
13
votes
2 answers
How to use Rails 3 scope to filter on habtm join table where the associated records don't exist?
I have an Author model which habtm :feeds. Using Rails 3 want to setup a scope that finds all authors that have no associated feeds.
class Author < ActiveRecord::Base
has_and_belongs_to_many :feeds
scope :without_feed,…

Midwire
- 1,090
- 8
- 25
13
votes
1 answer
SQL where clause on inner joins
I am working with pgadminIII (postgreSQL)
I have the following tables:
Book,
Publisher,
OrderLine,
ShopOrder.
With the following SQL:
SELECT
Book.BookID AS "Book ID"
,Book.Title AS "Book title"
,SUM(OrderLine.quantity) AS "Number…

Edward Savage
- 149
- 1
- 1
- 9
13
votes
5 answers
SQL Select Statement with WHERE, AND, OR
I would like to perform a SELECT query with MySQL. My goal is to select all the dogs in a vet database that would be sex=male and fur=short and (color=black or size=big)
Note: I want to select dogs that are either black or size is big. They don't…

dave
- 229
- 1
- 3
- 13
13
votes
1 answer
np.where Not Working in my Pandas
I have an np.where problem using Pandas that is driving me crazy and I can't seem to solve through Google, the documentation, etc.
I'm hoping someone has insight. I'm sure it isn't complex.
I have a df where I'm checking the value in one column -…

Windstorm1981
- 2,564
- 7
- 29
- 57
13
votes
3 answers
SELECT WHERE IN - mySQL
let's say I have the following Table:
ID, Name
1, John
2, Jim
3, Steve
4, Tom
I run the following query
SELECT Id FROM Table WHERE NAME IN ('John', 'Jim', 'Bill');
I want to get something like:
ID
1
2
NULL or 0
Is it possible?

vshale
- 167
- 1
- 1
- 9
13
votes
3 answers
How to Concat String in SQL WHERE clause
I have declared two variables in RAW sql
DECLARE @str nvarchar(max), @str1 nvarchar (max);
SET @str = " AND (c.BondSales_Confirmed <> -1)";
SET @str1 = " AND (c.BondSales_IssueType = 'REGULAR')";
My SQL query is:
SELECT * From t_BondSales Where…

Saquibul Islam Waheed
- 460
- 2
- 5
- 17
13
votes
2 answers
WHERE clause with nested multiple conditions
I want to retrieve data with conditions in WHERE clause.
Here is my table something look like:
Name Location Age
----------------------
AAA Bhuj 24
BBB Mumbai 22
CCC Bhuj 18
DDD Bhuj 27
EEE Mumbai …

Himanshu
- 31,810
- 31
- 111
- 133
13
votes
2 answers
Delete SQLite Row with where clause with multiple clauses
I've been searching around and not managed to find a solution or working example so here goes.
I've set up an SQLite database which has five columns with different fields which effectively builds a list for the user. There will be multiple values in…

Gareth Bowen
- 341
- 2
- 3
- 11