mysql .. retrieving if true ..

mokatell
mokatell used Ask the Experts™
on
+-------+-----------+----------
| appID | empid | finished
+-------+-----------+----------
|     5 |         2 |        1
|     5 |         5 |        0
|     5 |         6 |        0
|     9 |         3 |        0
|     9 |         6 |        0
|    21 |         3 |        0
|    21 |         6 |        0
|    21 |         7 |        0
|    21 |         4 |        0
|    26 |         2 |        0
|    26 |         4 |        0
|    26 |         6 |        0
|    22 |         4 |        1
|    22 |         5 |        1
|    22 |         6 |        1
|    22 |         3 |        1
|    22 |         7 |        1
|    20 |         2 |        0
|    11 |         0 |        0
|     8 |         5 |        0
|     8 |         3 |        0
|     4 |         2 |        1
|     4 |         6 |        0
|     7 |         5 |        1
|     7 |         6 |        1
|     7 |         2 |        1
|     6 |         5 |        1
|     6 |         3 |        0
|     6 |         7 |        1

for example ...
in this table ... i wanna get all the appid where its ALL relavent finished column is '1'
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
which of the columns are to be considered as relevent , you can just select the columns where finished is 1

select *  from <table_name> where finished = '1'

Author

Commented:
no , ... i know that this is very simple ..
for example ..
i wanna a query that gives me back

appID
---------
7
22

because ALL their relvant columns are '1' ... got me now !??

Commented:
select appID, finished  from <table_name> where finished = '1'
or
select DISTINCT appID, finished  from <table_name> where finished = '1'
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Author

Commented:
this is not what i want ..
because on what u hace said will also include appID 6 , 5  and 4 ... but i want only 7 & 22 becasue 7 and 22 all the finished columns for them is '1'.......

my question is very clear ..
you can use a sub-query

select distinct appid from example where finished = '1' and appid not in (select distinct appid from example where finished = '0');

Author

Commented:
fine ..now i got the finished apps

how can i mix your query with this one :

this query reads from two tables --->

select t1.appid,t1.username,t2.fax from account_information t1 join personal_information t2 on t1.appID= t2.appID ;
select t1.appid,t2.fax,t1.finished from example t1 join example1 t2 on t1.appID= t2.appID
where t1.finished = '1' and t1.appid NOT IN (select distinct appid from example where finished = '0');

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial