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
3 answers

How can I SELECT rows that are not number

How can I select rows in MySQL that are not numbers? SELECT * FROM `TABLE` WHERE `Column_B` <> Number I know, this is a stupid question, but I haven't found a solution for this. Column_B is varchar(3).
Peter
  • 1,224
  • 3
  • 16
  • 28
2
votes
1 answer

Mysql Stored procedure issue with varchar variable in where clause

I have a problem in mysql stored procedures where the varchar variable in the where clause doesn't return the results. The query is given below. declare itcode varchar(30); declare qty int; declare finished int; declare testc cursor for select…
User 99x
  • 1,011
  • 1
  • 13
  • 39
2
votes
3 answers

IN Clause with WHERE clause not getting proper results in SQL Server

SELECT Col1, Col2, Col3, Col4 FROM Table1 WHERE User1 = @Owner AND group1 = @Group AND date1 BETWEEN @startDate AND @endDate AND Mail LIKE @email AND def IN (CASE @InvoiceMethod //Problem is Here WHEN '' …
Lalita
  • 153
  • 2
  • 4
  • 16
2
votes
2 answers

SELECT * FROM WHERE does not find all records

When I type: select * from 'saleslog' where 'Status' = 'Pending'; or select * from 'saleslog' where 'Status' = "Pending"; or select * from saleslog where Status = 'Pending'; despite the fact that there are hundreds of rows with "Pending" value in…
user3387040
  • 65
  • 1
  • 2
  • 9
2
votes
4 answers

next method (Class.first) doesn't work after Rails update 4.1.0

I have a model which look like this: class Question < ActiveRecord::Base belongs_to :level def next Question.first(:conditions => ['id > ? AND level_id = ?', self.id, self.level_id], :order => 'id ASC') end end This worked…
2
votes
2 answers

SQL Server: Select * from x where (a,b) in (select a,b from z)

This does not work in SQL Server: SELECT ID, SQNCNO FROM JUID AS MID WHERE (ID, SQNCNO) IN (SELECT NM.ID, NM.SQNCNO FROM JUNM AS NM WHERE (LAST_NAME LIKE 'TESTCASE%')) ORDER BY ID, SQNCNO It works…
user3586521
  • 63
  • 1
  • 2
  • 5
2
votes
2 answers

What is the best way to dynamically add to a where clause in a nhibernate query in C#?

I have a some C# code that is querying a database using nhibernate that looks like this: public void Query() { IEnumerable list = session.Query() .Where(p => !p.IsDeleted) .FetchMany(r…
leora
  • 188,729
  • 360
  • 878
  • 1,366
2
votes
2 answers

pl/sql query optimization with function call in where clause

I am trying to optimize a query where I am using a function() call in the where clause. The function() simply changes the timezone of the date. When I call the function as part of the SELECT, it executes extremely fast (< 0.09 sec against table of…
bbaley
  • 199
  • 6
  • 22
2
votes
1 answer

Database field in IN condition

I'm trying to use a database field in a IN sql condition. My field is a string of values separated by a comma (like this it,en,fr,de) and I have to use it in a WHERE clause like this: WHERE d.iso639code = c.main_language_isocode OR d.iso639code IN…
2
votes
4 answers

SQL Server, choosing from two TABLEs using IF statement inside WHERE statement depending on the parameter

How can I do the following in SQL Server DECLARE @Local nvarchar(20) SET @Local = 'True' SELECT * FROM My_Table WHERE my_ID IN (IF @Local = 'True' SELECT AllIDs FROM ATable ELSE SELECT TeamIDs FROM TeamTable …
stckvrflw
  • 1,489
  • 3
  • 22
  • 37
2
votes
4 answers

Why do WHERE and HAVING exist as separate clauses in SQL?

I understand the distinction between WHERE and HAVING in a SQL query, but I don't see why they are separate clauses. Couldn't they be combined into a single clause that could handle both aggregated and non-aggregated data?
2
votes
1 answer

Is it possible to have a CASE WHEN THEN SELECT in a WHERE CLAUSE

I was just wondering if it would be possible to have a CASE statement in a WHERE clause exactly in this form... SELECT * FROM TABLEA WHERE date between '2014-02-01' and '2014-02-28' and CASE WHEN date>'2014-02-28' THEN (SELECT FROM TABLEC…
ltsai
  • 757
  • 3
  • 8
  • 16
2
votes
1 answer

android sql where clause with id

Problem solved, look at comment below I'm trying to update a database, but the where clause doesn't work. I already looked at code samples, but they don't work for me. This is how the table looks. public static final String SQL_CREATE_ENTRIES = …
Simon
  • 53
  • 5
2
votes
2 answers

Filter table before inner join condition

There's a similar question here, but my doubt is slight different: select * from process a inner join subprocess b on a.id=b.id and a.field=true and b.field=true So, when using inner join, which operation comes first: the join or the a.field=true…
Yoshimit
  • 31
  • 1
  • 4
2
votes
1 answer

CASE in WHERE CLAUSE in MYSQL

The question is as simple as the title says,But here is one logic. Here is my code CREATE TABLE `inf_brand_images` ( `id` bigint(99) NOT NULL AUTO_INCREMENT, `brand` varchar(255) NOT NULL, `thumb` text NOT NULL, `is_active` int(2) NOT NULL DEFAULT…
user3244721
  • 714
  • 2
  • 11
  • 29
1 2 3
99
100