S
S
Sama Samsonov2017-02-16 08:59:47
MySQL
Sama Samsonov, 2017-02-16 08:59:47

How to fix this request?

How to fix this request?

SELECT COUNT(*)
      FROM joiners_tourdate
        JOIN joiners_country on joiners_tourdate.country_id = joiners_country.id
      WHERE joiners_tourdate.artist_id = joiners_artist.id
      AND joiners_tourdate.country_id = 3

joiners_artist.id not found here ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yevgeniy Kisselyov, 2017-02-16
@samuser

Either way

SELECT COUNT(*)
FROM joiners_tourdate, joiners_artist
JOIN joiners_country on joiners_tourdate.country_id = joiners_country.id
WHERE joiners_tourdate.artist_id = joiners_artist.id
AND joiners_tourdate.country_id = 3

Or change it to join
SELECT COUNT(*)
FROM joiners_tourdate 
JOIN joiners_country on joiners_tourdate.country_id = joiners_country.id
JOIN joiners_artist ON joiners_tourdate.artist_id = joiners_artist.id
WHERE joiners_tourdate.country_id = 3

I
Ilya, 2017-02-16
@rpsv

Because you don't have it ?
Add it to JOIN:

SELECT COUNT(*)
FROM joiners_tourdate
INNER JOIN joiners_country on joiners_tourdate.country_id = joiners_country.id
INNER JOIN joiners_artist on joiners_artist.id = joiners_tourdate.artist_id
WHERE joiners_tourdate.country_id = 3

D
d-stream, 2017-02-16
@d-stream

And what is within this query joiners_artist.id ? What horrible id from joiners_artist table?
How would a pair of tables be specified, and in the condition a third one suddenly appears ... It turns out "a pen is attached to the file, how old is the train driver?" -)
Apparently, for example, the higher select from joiners_artist was lost - then everything will fall into place. Or you need to somehow join the joiners_artist table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question