-1

I'm just having a problem with a query. I have two tables employe and tournee.

employe

tournee

I need to select the name (nom) of all the employes who made less than 4 tour (tournee).

I used this query : query

but the problem is that I have "#1242 - Subquery returns more than 1 row"

I tried to use WHERE .. IN instead of WHERE but not relly sure how to use it

Thanks for your help !

  • Search the net for "correlated sub-queries" and that will both solve the puzzle for you, and aid in your learning. *(For now, please don't use images for code, error messages, data, etc. Stackoverflow has formatting tools for that, so you can paste it in as text and we can copy it if necessary to help write an answer.)* – MatBailie Jun 19 '22 at 15:48
  • 1
    [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – Luuk Jun 19 '22 at 17:16

1 Answers1

0

You can use HAVING clause to get only those employees who made less than 4 tours. Here is an example

SELECT E.Nom
FROM employe E
LEFT JOIN tournee T
  ON E.NoEmploye = T.NoEmploye
GROUP BY E.Nom
HAVING COUNT(T.NoTournee) < 4
GoonerForLife
  • 631
  • 2
  • 5