I have two tables i need to query
One called horse which contains the Name and Horse_id
One called entry which contains the Horse_id and the Place. (Place is the where the horse came, eg. 1st, 2nd, 3rd).
I need to use a subquery to display the horse Name and Id of every horse that has won a 1st 2nd or 3rd more than once.
So far i have (i haven’t gotten to the “more than once” part yet)
SELECT horse_id, name FROM
(SELECT count(place) AS horse_id, name FROM entry)
WHERE entry.place<3;
Although this isn’t working. Error is “every derived table must have its own alias”. I’m not sure what i’m supposed to name and i’m finding it hard to find examples of this type of query.
I also tried:
SELECT horse_id, name FROM horse
WHERE place IN(SELECT horse_id FROM entry WHERE entry.place<3);
Not sure where i’m going wrong
I apologize, should have read the question better.. just created the tables on my system this works: