U
U
UNy2018-08-25 01:00:36
MySQL
UNy, 2018-08-25 01:00:36

EXISTS predicate?

I can't figure out how exists works. Here is an example:

SELECT ship FROM Outcomes os
WHERE EXISTS (SELECT ship 
 FROM Outcomes oa
 WHERE oa.ship = os.ship AND 
 result = 'damaged'
 )

In theory, all ships from outcomes should be selected if exists returns true, why then only those ships where result='damaged' are displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-08-25
@UNy

Well, you choose in exists by the condition result = damaged what do you want it to display?
But in general, the meaning is generally incomprehensible, in the same table, why make such a selection.
The same as such a request is obtained

SELECT ship FROM Outcomes os
WHERE  result = 'damaged'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question