Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

sql - How to use WHERE and INNER JOIN together

Selected name, surname and sum of costs but it doesn't work. Is using WHERE possible here?

SELECT DISTINCT ad, soyad, SUM(gunluk_ucret) AS toplam
FROM Kart as k
INNER JOIN musteri ON k.TCNO=musteri.TCNO 
INNER JOIN ekipman ON k.ekipman_id=ekipman.ekipman_id
GROUP BY ad,soyad,gunluk_ucret;
question from:https://stackoverflow.com/questions/65546146/how-to-use-where-and-inner-join-together

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your query, the group by keys and select keys are not consistent. Perhaps that is the problem you are asking about:

SELECT ad, soyad, SUM(gunluk_ucret) AS toplam
FROM Kart k INNER JOIN
     musteri m
     ON k.TCNO = m.TCNO INNER JOIN
     ekipman e
     ON k.ekipman_id = e.ekipman_id
GROUP BY ad, soyad;

You should qualify all column references in the query. I don't know what tables the columns come from, so I cannot make any suggests there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...