I try to create a view from my tables. When I create a view like this from 1 table it works nice:
CREATE VIEW v2 AS SELECT section_id, section_name, count(*) AS num, count(*) as num1 FROM section_of_science GROUP BY section_id; select * from v2; But when I try to create a view from two tables it doesn't work:
CREATE VIEW v3 AS SELECT section_of_science.section_id, section_of_science. section_name, scientific_areas.areas_name, count(*) AS num, count(*) as num1 FROM section_of_science, scientific_areas GROUP BY section_id; select * from v3; And I get this error:
Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'Lab3.scientific_areas.areas_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
what am I doing wrong?
Let me know if you need more information.
JOINsyntax. Easier to write (without errors), easier to read and maintain, and easier to convert to outer join if needed!GROUP BYthe same columns as youSELECT, except those who are arguments to set functions.