Similar questions | sql - How to use "and" and "or" in "where" clause
-
sql - Union with where clause
I'm doing a UNION of two queries on an Oracle database. Both of them have a WHERE clause. Is there a difference in the performance if I do the WHERE after UNIONing the queries ...
-
sql - Does MySQL not use an index with a where in clause?
I'm trying to optimize some of the database queries in my Rails app and I have several that have got me stumped. They are all using an IN in the WHERE clause and are all doing...
-
sql - Use aliases in the where clause
I have a query which is meant to show me any rows in table A which have not been updated recently enough. (Each row should be updated within 2 months after "month_no".): SELEC...
-
sql - Left where clause
I need to retrieve all default settings from the settings table but also grab the character setting if exists for x character. But this query is only retrieving those settings where character is...
-
sql server - SQL: if clause in where clause
Is it possible to use an IF clause within a WHERE clause in MS SQL? Example: WHERE IF IsNumeric(@OrderNumber) = 1 OrderNumber = @OrderNumber ELSE OrderNumber LIKE '%' + @...
-
SQL join: where clause and on Clause
After reading it, this is not a duplicate of Explicit vs Implicit SQL Joins. The answer may be related (or even the same) but the question is different. What is the difference and what should g...
-
mysql - CodeIgniter: how to use where clause and or clause
I am using the following code to select from a MySQL database with a Code Igniter webapp: $query = $this->db->get_where('mytable',array('id'=>10)); This works great! But I w...
-
sql - Distinct clause with where
How can I use the DISTINCT clause with WHERE? For example: SELECT * FROM table WHERE DISTINCT email; -- email is a column name I want to select all columns from a table with...
-
sql server - Where clause in SQL
I'm trying to implement optional parameters in a stored procedure that I have but I am running into a problem. Here's a simplified query to illustrate the issue: SET ANSI_NULL...
-
SQL - Use Max in where clause
Assume value is an int and the following query is valid: SELECT blah FROM table WHERE attribute = value Though MAX(expression) returns int, the following is not valid: SELE...