Exclude a row after returning it from a subquery mysql

Carlos Delgado

Hi this is what I need: "Display the name and salary of all employees working on the same Department than 'Mike'. The result shouldn't include 'Mike' "

So I have this query:

SELECT E.Name,E.Salary FROM E WHERE E.DepWorking = (SELECT DepWorking FROM E WHERE Name = 'Mike');

and I get all the employees working in the same department than Mike but it is showing Mike's row too and I don't want that, how can I avoid Mike to show up??

Felix Pamittan

Add an additional condition in the WHERE clause:

SELECT 
    E.Name,E.Salary 
FROM E 
WHERE 
    E.DepWorking IN (SELECT DepWorking FROM E WHERE Name = 'Mike')
    AND E.Name <> 'Mike'
;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

mysql subquery only returning one row

From Dev

Returning a value 0 from a database row in PHP/MySQL after a query

From Dev

Exclude result from mysql_fetch_row()

From Dev

Exclude row from MySQL older than today

From Dev

Mysql Subquery returns more than 1 row from many databases

From Dev

Mysql Subquery returns more than 1 row from many databases

From Dev

How to do LEFT JOIN two tables and exclude multiple rows from main query in subquery using MySQL?

From Dev

MySQL row subquery comparison issue

From Dev

MySQL - max( ) row values of subquery

From Dev

MYSQL count subquery on current row

From Dev

Mysql subquery return multiple row

From Dev

subquery as the from for mysql

From Dev

SQLAlchemy: exclude rows taken from a subquery on a query

From Dev

UPDATE with subquery returning EMPTY/NULL MYSQL

From Dev

MySql subquery runs instead of returning error

From Dev

MySQL: Returning multiple columns from an in-line subquery with complex date comparison operators

From Dev

Java mysql query ("SELECT * FROM movies" is only returning 1 row

From Dev

MySQL: Returning total record count from a CROSS JOINed row?

From Dev

MySQL Select only returning one row from eclipse

From Dev

Returning multiple aggregated columns from Subquery

From Dev

MySQL subquery returns more than one row selecting count with subquery

From Dev

Exclude one row from range

From Dev

Exclude first row from macro

From Dev

Exclude first row from group

From Dev

How to resolve Subquery returning more than 1 row

From Dev

MYSQL insert from one table to another but gets error: subquery returns more than 1 row

From Dev

MySQL should return row if subquery has no result

From Dev

Converting Previous Row Subquery into a Join in MySQL

From Dev

Subquery return more than 1 row MySQL

Related Related

  1. 1

    mysql subquery only returning one row

  2. 2

    Returning a value 0 from a database row in PHP/MySQL after a query

  3. 3

    Exclude result from mysql_fetch_row()

  4. 4

    Exclude row from MySQL older than today

  5. 5

    Mysql Subquery returns more than 1 row from many databases

  6. 6

    Mysql Subquery returns more than 1 row from many databases

  7. 7

    How to do LEFT JOIN two tables and exclude multiple rows from main query in subquery using MySQL?

  8. 8

    MySQL row subquery comparison issue

  9. 9

    MySQL - max( ) row values of subquery

  10. 10

    MYSQL count subquery on current row

  11. 11

    Mysql subquery return multiple row

  12. 12

    subquery as the from for mysql

  13. 13

    SQLAlchemy: exclude rows taken from a subquery on a query

  14. 14

    UPDATE with subquery returning EMPTY/NULL MYSQL

  15. 15

    MySql subquery runs instead of returning error

  16. 16

    MySQL: Returning multiple columns from an in-line subquery with complex date comparison operators

  17. 17

    Java mysql query ("SELECT * FROM movies" is only returning 1 row

  18. 18

    MySQL: Returning total record count from a CROSS JOINed row?

  19. 19

    MySQL Select only returning one row from eclipse

  20. 20

    Returning multiple aggregated columns from Subquery

  21. 21

    MySQL subquery returns more than one row selecting count with subquery

  22. 22

    Exclude one row from range

  23. 23

    Exclude first row from macro

  24. 24

    Exclude first row from group

  25. 25

    How to resolve Subquery returning more than 1 row

  26. 26

    MYSQL insert from one table to another but gets error: subquery returns more than 1 row

  27. 27

    MySQL should return row if subquery has no result

  28. 28

    Converting Previous Row Subquery into a Join in MySQL

  29. 29

    Subquery return more than 1 row MySQL

HotTag

Archive