Questions tagged [where-clause]

A syntactic form in functional languages used to bind a value to a name in a local scope. Similar, but not identical to, let.

9069 questions
71
votes
2 answers

Oracle SQL : timestamps in where clause

I need to look up rows within a particular time frame. select * from TableA where startdate >= '12-01-2012 21:24:00' and startdate <= '12-01-2012 21:25:33' I.e.: I need to look up rows with timestamp precision of SECONDS. How do I achieve…
sid
  • 895
  • 3
  • 10
  • 14
70
votes
2 answers

MySQL Select last 7 days

I read some posts here and seems like nothing special but I can not still select the entries of the last days. SELECT p1.kArtikel, p1.cName, p1.cKurzBeschreibung, p1.dLetzteAktualisierung, p1.dErstellt, p1.cSeo, …
karadayi
  • 2,212
  • 2
  • 21
  • 36
70
votes
10 answers

Is a JOIN faster than a WHERE?

Suppose I have two tables that are linked (one has a foreign key to the other): CREATE TABLE Document ( Id INT PRIMARY KEY, Name VARCHAR 255 ) CREATE TABLE DocumentStats ( Id INT PRIMARY KEY, DocumentId INT, -- this is a foreign key to…
Wookai
  • 20,883
  • 16
  • 73
  • 86
69
votes
10 answers

Dynamic WHERE clause in LINQ

What is the best way to assemble a dynamic WHERE clause to a LINQ statement? I have several dozen checkboxes on a form and am passing them back as: Dictionary> (Dictionary>) to my LINQ query. public…
Keith Barrows
  • 24,802
  • 26
  • 88
  • 134
65
votes
6 answers

What is the purpose of using WHERE 1=1 in SQL statements?

Possible Duplicates: Why would a sql query have “where 1 = 1” Why would someone use WHERE 1=1 AND in a SQL clause? I've seen that a lot in different query examples and it goes to probably all SQL engines. If there is a query that has…
RaYell
  • 69,610
  • 20
  • 126
  • 152
64
votes
7 answers

Checking an input param if not Null and using it in where in SQL Server

What is the best way to include an input param in the WHERE clause but exclude it if it is null? There are a number of ways I believe, but I can't seem to remember then. Also could I use the COALESCE()? But I think this is only for SELECTing…
Martin
  • 23,844
  • 55
  • 201
  • 327
63
votes
3 answers

Usage of where in if let assignment in Swift

The Swift documentation at page 61 of the Swift manual hints to the possibility of using where to join an optional binding with a regular condition. Yet when I do it I have a warning suggesting me to substitute the where with a comma like in the…
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
63
votes
6 answers

In SQL / MySQL, what is the difference between "ON" and "WHERE" in a join statement?

The following statements give the same result (one is using on, and the other using where): mysql> select * from gifts INNER JOIN sentGifts ON gifts.giftID = sentGifts.giftID; mysql> select * from gifts INNER JOIN sentGifts WHERE gifts.giftID =…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
60
votes
4 answers

sql query if parameter is null select all

Can the following query be modified to return all records if the ? is null? SELECT NAME, SURNAME FROM MY_TABLE WHERE NAME = ?;
Fseee
  • 2,476
  • 9
  • 40
  • 63
59
votes
4 answers

Selecting rows where remainder (modulo) is 1 after division by 2?

There is a column in options that hold an integer. I want to select the row only if that value % 2 = 1. I know this can be done in 2 queries but is it possible to do it in 1?
Carlos
  • 681
  • 2
  • 6
  • 4
58
votes
4 answers

MySql Inner Join with WHERE clause

Here is my code: SELECT table1.f_id FROM table1 WHERE table1.f_com_id = '430' AND table1.f_status = 'Submitted' INNER JOIN table2 ON table2.f_id = table1.f_id where table2.f_type = 'InProcess' I need information from table1 as all the…
Aditya Kumar
  • 793
  • 1
  • 8
  • 14
57
votes
5 answers

Oracle date "Between" Query

I am using oracle database. I want to execute one query to check the data between two dates. NAME START_DATE ------------- ------------- Small Widget 15-JAN-10 04.25.32.000000 PM Product 1 17-JAN-10…
Gnaniyar Zubair
  • 8,114
  • 23
  • 61
  • 72
56
votes
6 answers

How can I have IS NULL condition in TypeORM find options?

In my queries I'm using TypeORM find option. How can I have IS NULL condition in the where clause?
user4092086
  • 986
  • 3
  • 12
  • 24
52
votes
1 answer

How to use numpy.where with logical operators

I'm trying to find the indices of all elements in an array that are greater than a but less than b. It's probably just a problem with my syntax but this doesn't work: numpy.where((my_array > a) and (my_array < b)) How should I fix this? Or is there…
ylangylang
  • 3,294
  • 11
  • 30
  • 34
49
votes
3 answers

Can I use 'where' inside a for-loop in swift?

Is there also a possibility to use the 'where' keyword in another place then a switch? Can I use it in a for in loop for example? I have an array with bools, all with a value, can I do something like this: var boolArray: [Bool] = [] //(...) set…
Simon
  • 2,419
  • 2
  • 18
  • 30