/    /  MySQL – Exists

MySQL – Exists



MySQL’s EXISTS operator is a type of Boolean operator that evaluates to true or false. As part of a subquery, it determines whether or not data exists in the subquery. The operator returns true if a subquery returns any records. Otherwise, a false value will be returned. A true value is always represented by the numeric value 1, whereas a false value has the numeric value 0. We can use it with the SELECT, UPDATE, DELETE, and INSERT statements.


SELECT column_name(s)
FROM table_name
(SELECT column_name FROM table_name WHERE condition);


SELECT first_name
FROM employees
WHERE EXISTS (SELECT dept_no FROM dept_emp WHERE employees.emp_no =dept_emp.emp_no AND salary  > 15000);

MySQL - Not Equal