Link to home
Start Free TrialLog in
Avatar of mokatell
mokatell

asked on

mysql .. retrieving if true ..

+-------+-----------+----------
| 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'
Avatar of max2jhonny
max2jhonny

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'
Avatar of mokatell

ASKER

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 !??
select appID, finished  from <table_name> where finished = '1'
or
select DISTINCT appID, finished  from <table_name> where finished = '1'
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 ..
ASKER CERTIFIED SOLUTION
Avatar of max2jhonny
max2jhonny

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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');