Skip to content
Advertisement

My MySQL select shows only 1 result instead of all that I chose

I have a problem with this mysql exercise, could someone help me so it displays all the records I want, because now it only takes a value from the column tytul and it gives the max, min and avg from the whole table instead of separating them and then counting the max, min and avg from each tytul

Advertisement

Answer

Basically, your query misses a GROUP BY clause at its end:

You should also use standard, explicit joins (with the ON keyword) rather than old-school, implicit joins (with commas in the from clause); finally, I would recommend using table aliases to shorten the query and make it more readable:

Please note that I removed the double quotes around column aliases; in MySQL you need to use backticks for identifiers – or better yet, use identifiers that do not conflict with SQL keywords, and hence to not need to be quoted.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement