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
127
votes
6 answers

MySQL - ORDER BY values within IN()

I'm hoping to sort the items returned in the following query by the order they're entered into the IN() function. INPUT: SELECT id, name FROM mytable WHERE name IN ('B', 'A', 'D', 'E', 'C'); OUTPUT: | id | name | ^--------^---------^ | 5 …
Matt
  • 3,778
  • 9
  • 35
  • 36
127
votes
2 answers

C# generic "where constraint" with "any generic type" definition?

Let me give example: I have some generic class/interface definition: interface IGenericCar< T > {...} I have another class/interface that I want to relate with class above, for example: interface IGarrage< TCar > : where TCar: IGenericCar< (**any…
Nenad
  • 24,809
  • 11
  • 75
  • 93
117
votes
6 answers

MySQL select with CONCAT condition

I'm trying to compile this in my mind.. i have a table with firstname and lastname fields and i have a string like "Bob Jones" or "Bob Michael Jones" and several others. the thing is, i have for example Bob in firstname, and Michael Jones in…
Alex K
  • 6,737
  • 9
  • 41
  • 63
114
votes
15 answers

Get only records created today in laravel

How do I use the created_at field to get only the records that were created today and no other day or time? I was thinking of a ->where('created_at', '>=', Carbon::now()) But Im not sure that would work.
TheWebs
  • 12,470
  • 30
  • 107
  • 211
110
votes
6 answers

How to write a SQL DELETE statement with a SELECT statement in the WHERE clause?

Database: Sybase Advantage 11 On my quest to normalize data, I am trying to delete the results I get from this SELECT statement: SELECT tableA.entitynum FROM tableA q INNER JOIN tableB u on (u.qlabel = q.entityrole AND u.fieldnum = q.fieldnum)…
LuiCami
  • 1,241
  • 2
  • 8
  • 8
109
votes
3 answers

querying WHERE condition to character length?

I have a database with a large number of words but i want to select only those records where the character length is equal to a given number (in example case 3): $query = ("SELECT * FROM $db WHERE conditions AND length = 3"); But this does not…
faq
  • 2,965
  • 5
  • 27
  • 35
109
votes
4 answers

Filter Table Before Applying Left Join

I have 2 tables, I want to filter the 1 table before the 2 tables are joined together. Customer Table: ╔══════════╦═══════╗ ║ Customer ║ State ║ ╠══════════╬═══════╣ ║ A ║ S ║ ║ B ║ V ║ ║ C ║ L ║ …
Tom Jenkin
  • 1,925
  • 2
  • 15
  • 11
108
votes
10 answers

SQL WHERE condition is not equal to?

Is it possible to negate a where clause? e.g. DELETE * FROM table WHERE id != 2;
Frank Vilea
  • 8,323
  • 20
  • 65
  • 86
106
votes
6 answers

"Or" equivalent in Linq Where() lambda expression

Is there a method in Linq where you can use to build SQL strings like "...where (a=1) OR (a=2)"?
dstr
  • 8,362
  • 12
  • 66
  • 106
106
votes
7 answers

SQL server ignore case in a where expression

How do I construct a SQL query (MS SQL Server) where the "where" clause is case-insensitive? SELECT * FROM myTable WHERE myField = 'sOmeVal' I want the results to come back ignoring the case
Raul Agrait
  • 5,938
  • 6
  • 49
  • 72
93
votes
12 answers

SELECTING with multiple WHERE conditions on same column

Ok, I think I might be overlooking something obvious/simple here... but I need to write a query that returns only records that match multiple criteria on the same column... My table is a very simple linking setup for applying flags to a user ... ID …
90
votes
5 answers

EF: Include with where clause

As the title suggest I am looking for a way to do a where clause in combination with an include. Here is my situations: I am responsible for the support of a large application full of code smells. Changing too much code causes bugs everywhere so I…
Beejee
  • 1,836
  • 2
  • 17
  • 31
89
votes
6 answers

Conditional WHERE clause in SQL Server

I am creating a SQL query in which I need a conditional where clause. It should be something like this: SELECT DateAppr, TimeAppr, TAT, LaserLTR, Permit, LtrPrinter, JobName, JobNumber, JobDesc, ActQty, …
user2721874
86
votes
4 answers

In Haskell, when do we use in with let?

In the following code, the last phrase I can put an in in front. Will it change anything? Another question: If I decide to put in in front of the last phrase, do I need to indent it? I tried without indenting and hugs complains Last generator in…
McBear Holden
  • 5,741
  • 7
  • 33
  • 55
83
votes
2 answers

pandas equivalent of np.where

np.where has the semantics of a vectorized if/else (similar to Apache Spark's when/otherwise DataFrame method). I know that I can use np.where on pandas.Series, but pandas often defines its own API to use instead of raw numpy functions, which is…
max
  • 49,282
  • 56
  • 208
  • 355