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
22
votes
7 answers

MYSQL use 'LIKE' in 'WHERE' clause to search in subquery

How would you use 'LIKE' to search in a subquery? E.g. i've tried doing this, but doesn't work: SELECT * FROM mytable WHERE name LIKE '% (SELECT name FROM myothertable) %' I have this so far: SELECT * FROM t1 WHERE t1.name IN…
qwerty
  • 223
  • 1
  • 2
  • 5
21
votes
4 answers

mySQL returns all rows when field=0

I was making some tests, and it was a surprise when i was querying a table, and the query SELECT * FROM table WHERE email=0 returned all rows from the table. This table has no '0' values and it's populated with regular e-mails. Why this happens?…
AFRC
  • 902
  • 3
  • 9
  • 27
21
votes
1 answer

Pandas, loc vs non loc for boolean indexing

All the research I do point to using loc as the way to filter a dataframe by a col(s) value(s), today I was reading this and I discovered by the examples I tested, that loc isn't really needed when filtering cols by it's values: EX: df =…
Miguel
  • 1,579
  • 5
  • 18
  • 31
21
votes
2 answers

Postgres SELECT statement where field value ends with

I have a postgres database table called: web_data Currently i'm running the following SQL select statement: SELECT url_path FROM web_data WHERE url_path IS NOT NULL Here are some example results I will get for…
Ahmed
  • 1,403
  • 4
  • 21
  • 44
21
votes
6 answers

using CASE in T-SQL in the where clause?

Im trying to use case to vary the value im checking in a where clause but I'm getting the error: incorrect syntax near the keyword 'CASE' SQL Server 2005 select * from table where ((CASE when adsl_order_id like '95037%' then select…
fatjoez
  • 211
  • 1
  • 2
  • 5
21
votes
3 answers

is there any way for multiple where statement in Haskell

i tried to write 3-4 where statement in a one function but i get error and couldnt do it , i tried to do something like that : foo x= | x == foo1 = 5 | x == foo2 =3 | x == foo3 =1 | otherwise =2 where foo1= samplefunct1 x foo2= samplefunct2…
20
votes
9 answers

SQL Server: Multiple table joins with a WHERE clause

I'm using SQL Server and I'm having a difficult time trying to get the results from a SELECT query that I want. I've tried joining in different orders and using subqueries but nothing quite works the way I want. Take this contrived example of…
Stormchao
  • 260
  • 1
  • 2
  • 8
20
votes
5 answers

Why does putting a WHERE clause outside view have terrible performance

Let's say you have a view: CREATE VIEW dbo.v_SomeJoinedTables AS SELECT a.date, a.Col1, b.Col2, DENSE_RANK() OVER(PARTITION BY a.date, a.Col2 ORDER BY a.Col3) as Something FROM a JOIN b on a.date = b.date I've found that the…
bpeikes
  • 3,495
  • 9
  • 42
  • 80
20
votes
7 answers

SQL - improve NOT EXISTS query performance

Is there a way I can improve this kind of SQL query performance: INSERT INTO ... WHERE NOT EXISTS(Validation...) The problem is when I have many data in my table (like million of rows), the execution of the WHERE NOT EXISTS clause if very slow. I…
Melursus
  • 10,328
  • 19
  • 69
  • 103
20
votes
4 answers

MySQL - Is it possible to use LIKE on all columns in a table?

I'm trying to make a simple search bar that searches through my database for certain words. It is possible to use the LIKE attribute without using WHERE? I want it to search all columns for the keywords, not just one. Currently I have…
user2566387
  • 211
  • 1
  • 2
  • 7
20
votes
5 answers

It's possible to have a WHERE clause after a HAVING clause?

Is it possible to use a WHERE clause after a HAVING clause? The first thing that comes to my mind is sub queries, but I'm not sure. P.S. If the answer is affirmative, could you give some examples?
cc.
  • 5,533
  • 14
  • 37
  • 46
20
votes
2 answers

Dynamic where clause (OR) in Linq to Entities

In the post here I learned how to build a dynamic query using the deferred execution of Linq. But the query is actually using an AND concatenation of the WHERE condition. How can I achieve the same query but with an OR logic? Due to the Flags…
20
votes
3 answers

Should I add an index for all fields in the WHERE clause? - MySQL

In my program I have very few inserts, and any which are run frequently are not needed instantly and therefore have been changed to INSERT DELAYED. Should I go through my code and see which fields are referenced in the WHERE clause and add an index…
Keir Simmons
  • 1,634
  • 7
  • 21
  • 37
20
votes
1 answer

WHERE clause in SSRS expression

What's the syntax for inserting a WHERE clause in an SSRS expression? I am using BIDS 2008. =Sum(Fields!QuantityToShip.Value) WHERE FIELDS!Program.Value = "FC" The code listed above represents the logic I want to use, but obviously inserting the…
sion_corn
  • 3,043
  • 8
  • 39
  • 65
19
votes
2 answers

In Haskell, what is the scope of a where clause when dealing with guards?

I know they do not hold across pattern matches (i.e. you need to rewrite the 'where' clause for each pattern), but how does the scoping work for guards? e.g. Does this work? myFunction x1 x2 | x1 > x2 = addOne x1 | x1 < x2 = addOne x2 |…
danieltahara
  • 4,743
  • 3
  • 18
  • 20