V
V
Viktoria Smirnova2019-02-04 19:58:37
PostgreSQL
Viktoria Smirnova, 2019-02-04 19:58:37

How to make a query to all rows in the database where the value is, for example, "yes"?

Good day to all, I
apologize in advance for the lamer question,
is it possible in Postgres to request that rows with columns where the column value = 'yes' be shown?
DB:
-----------door1 ---door2 --- door3 Line
1 -- no--------yes-------no
Line 2 -- no - ------ no-------yes
Line 3 -- no------- no-------no
result:
------------ -- ---
1st line ---door2
2nd line -- door3

select door1,door2, door3  from qualitytable WHERE door1,door2, door3 = 'yes';
- this is the wrong request, of course, but something like this is needed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Cherepakhin, 2019-02-04
@Vika7

select * from(
select stringid, "door1" val from qualitytable where door1 = 'yes'
union all
select stringid, "door2" val from qualitytable where door2 = 'yes'
union all
select stringid, "door3" val from qualitytable where door3 = 'yes'
)
string 1,2,... = stringid, i.e. there must be some row id.

A
Artem, 2019-02-04
@devspec

select door1,door2, door3  from qualitytable WHERE door1='yes' or door2='yes' or door3='yes';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question