Questions tagged [where]
The `WHERE` clause is used to specify criterion for retrieval or modification of rows from objects in a database.
9
questions
50
votes
2
answers
120k
views
selecting where two columns are in a set
This might be a silly question, and my suspicion is that I can't do this, but is there a construct in SQL that would allow me to do something like the following:
SELECT whatever WHERE col1,col2 IN ((...
3
votes
4
answers
3k
views
Building where clause based upon parameters
In PostgreSQL I am trying to build a where clause in a function that uses an inbound parameter to determine the contents of the IN
For example:
select fld1, count(fld1)
from xyz
where fld1 in (
...
7
votes
4
answers
27k
views
Building Dynamic Oracle Where Clause
I'm working on application that uses dynamic query to do a select statement based on user input, after discussing security with DBAs they want me to convert my dynamic select statement into Stored ...
1
vote
1
answer
3k
views
Error 1052 Field is Ambiguous using Inner Join Function
Error '1052' Field is ambiguous. I understand the error that is happening, and I've looked at several places for the fix and then applied the inner join function in attempt to fix it. It's still not ...
39
votes
3
answers
47k
views
Using column alias in a WHERE clause doesn't work
Given a table users with two fields: id and email.
select id, email as electronic_mail
from (
select id, email
from users
) t
where electronic_mail = ''
Postgres complains that:
...
7
votes
1
answer
15k
views
How do I query PostgreSQL enums like in MySQL?
With the following table in MySQL:
CREATE TABLE bob(foo ENUM('a','b','c'));
INSERT INTO bob (foo) VALUES ('a'),('b'),('c'),('a'),('a');
SELECT * FROM bob WHERE foo >= 2;
+------+
| foo |
+------...
1
vote
1
answer
2k
views
MySQL / MariaDB : Many indexes vs. One multi-column index
I need to optimize my MariaDB tables index.
I've read a lot of very interesting things on StackExchange, but I'm not sure to have the answer for my case.
In my case, I have a table named TableA which ...
1
vote
1
answer
161
views
Oracle: How can I create a where clause programmatically?
Suppose I have a table like:
TBL_CONDITIONS
| ID | WHERE_CLAUSE |
|----|---------------------------------------|
| 1 | fruit = 'apple' |
| 2 | ...
0
votes
1
answer
629
views
Is there any better way to list all the databases in Postgres except database named postgres?
SELECT datname FROM pg_database WHERE datistemplate = false AND datallowconn = true And datname NOT IN ('postgres')
Using the code above, I get all the databases except postgres as shown in the image ...