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
2
votes
1 answer

Oracle SQL Left and right outer Join with/Without where clause giving different outputs

Why is there a difference in output for the below queries? As per my understanding it should give the same output for the first 3 queries and same output for the last 3 queries. select count(*) from CTM_People a left outer join user_x b on…
Subbu
  • 41
  • 1
  • 8
2
votes
3 answers

Reuse field values in WHERE clause

How do I optimize the performance of the following T-SQL so heavyFunctionCall function will get called just once. Looking for the fastest option among table variables, temp tables, CTEsor something else? SQL: select dbo.heavyFunctionCall(a, b, c)…
user1514042
  • 1,899
  • 7
  • 31
  • 57
2
votes
1 answer

Laravel Equals Returning Empty In Where Clause

I have ran into a weird issue with Laravel where the equals sign does not return any values within a where clause. But the weirdest part is that if I use a != instead I get results! Widgets Table +----+-------------+-------------+ | id | title …
moonman
  • 51
  • 1
  • 6
2
votes
2 answers

Using switch-case with string in Linq where clause

I try to use where clause in my LINQ queries. When I use numerical value, it's fine but when I want to compare string value, it gives an error in where clause. string StartBarcode = (from s in datamodel.Packages …
nevra
  • 418
  • 1
  • 7
  • 21
2
votes
3 answers

Two "where" statements with one table doesn't work without subqueries

I've got a table with 3 columns: name, lastname and date. For example: Name Lastname Date Ab Ab 2008-07-01 Ab Ab 2006-06-23 Kb Kb 2008-07-01 Kb Kb 2007-06-03 I need to find the names of those who are assigned to…
Cassy_1
  • 73
  • 1
  • 7
2
votes
2 answers

How to add parameter to clause in PDO query

I am using code to run a Mysql query that defines a clasue ($datimeClause). I would like to run the query with a second parameter (:method) but if I change the syntax of the clause at all, the query won't run. I am fairly new to PDO could someone…
2
votes
1 answer

SQL Server: Multiple table joins with one or more WHERE clauses

I am running SQL Server and am trying to join multiple tables from CRM application but I can't get the result I need. I found this article SQL Server: Multiple table joins with a WHERE clause containing info close to what I am looking for, but I…
TrayS
  • 135
  • 2
  • 7
2
votes
2 answers

where clause in mysql "where 3"

I have fetch 3 highest salary from my table Here my query SELECT DISTINCT salary FROM salary e1 WHERE 3 = ( SELECT count( DISTINCT salary ) FROM salary e2 WHERE e1.salary >= e2.salary ) It's working fine but I want know, why we put condition…
Jaskaran Zap
  • 277
  • 1
  • 2
  • 9
2
votes
2 answers

Where clause magic in MySQL

I've found something in MySQL which astonished me a lot. I created a table and inserted records into it as below, CREATE TABLE `test` ( `ID` int, `NAME` varchar(100) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO test VALUES…
Yashwanth Aluru
  • 1,125
  • 6
  • 21
  • 28
2
votes
2 answers

If field = Null then use a different field

I have written some Sql code to display all clients who's offers are about to expire in the next 90 days by using the dateOffered field. However there is another field in the database called OfferExpirydate I would use this field however it it not…
RustyHamster
  • 359
  • 1
  • 5
  • 19
2
votes
2 answers

Rails where not is not finding nil values

I am trying to search to see if a posts value is either false or nil. Post.where.not(:top_card => true) This only returns the false values. I have confirmed that if I do either of the following it returns the correct values Post.where(:top_card =>…
Tall Paul
  • 2,398
  • 3
  • 28
  • 34
2
votes
1 answer

Convert SQL statement to Linq Statement (3 table left joins + where)

This is the working sql I need converted to Linq: select * from dbo.Pod p left join dbo.PodEvent pe on p.PodId = pe.Pod_PodId left join dbo.Event e on pe.Event_EventId = e.EventId where e.StartDateTime >= '2014-12-24 09:00:00.000' and…
OverMars
  • 1,077
  • 3
  • 16
  • 33
2
votes
2 answers

SQL WHERE Clause condition evaluation

I have an easy question, however I couldn't find the answer for this. In SQL WHERE clause which is better? TO_CHAR (DAT, 'YYYYMMDD') BETWEEN '20080101' AND '20131231' or DAT BETWEEN TO_DATE('20080101','YYYYMMDD') AND…
2
votes
1 answer

LINQ where query on a JToken

I'm new to LINQ query and I want to get 1 item (the one with id = 0) out of a JToken but I can't find out how this should be working. I tried a lot a different way but this the code I tried first : var statId0 = from stat in objectRankedStats where…
MHogge
  • 5,408
  • 15
  • 61
  • 104
2
votes
4 answers

SQL: Arrange numbers on a scale 1 to 10

I have a table in a SQL Server 2008 database with a number column that I want to arrange on a scale 1 to 10. Here is an example where the column (Scale) is what I want to accomplish with SQL Name Count (Scale) ---------------------- A 19 …
SunnyJones
  • 23
  • 3