E
E
er122015-04-13 15:18:44
MySQL
er12, 2015-04-13 15:18:44

How to ignore results when using the case when construct?

I have a question how to return only those results that are doubled in the inner query
select case when
exists(select 1 from table1 where table1.field1=1373369)
then
( table2.field1)
else
(select case when (
select 1 from ..... here is a complex selection from several tables linked by table2.field2
)=1 then
table2.field1
end as id
)
end from table2 where table2.field2=282
if the result of the inner query does not double the condition of equality 1, then an empty result will be displayed, how can I make it so that the value of table2.field1 or nothing is displayed, and not empty?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-04-13
@Rsa97

Well, like this

SELECT `t2`.`field1`
    FROM `table2` AS `t2`
    JOIN `table1` AS `t1` ON `t1`.`field1` = 1373369
    WHERE `t2`.`field2` = 282

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question