New answers tagged


DB Design Your tables are not correctly normalized: codes.description depends on codes.code → requires a table with codes.code as primary key You are also missing constraints: primary key unique key, additionalCredit.code primary key codes.codeId, codes.code primary key Query Optimization mysql does not come with a ...


If you don't want to use a subquery, you can include the second table with a join before the group by: SQL Fiddle SELECT max(name) name, SUM(amount) total FROM purchases INNER JOIN users on = purchases.user_id GROUP BY user_id ORDER BY user_id yielding name total Joe 600 Joey 700 Joe 100


LEFT JOIN from test_test to test_table selecting only rows where test_table.test_emp_id is null. select emp_id from test_test left join test_table on ( test_table.test_emp_id = test_test.emp_id and test_table.state = 'test_state' ) where ( test_test.flag = true and test_test.emp_id is not null and test_test.ver_id in ( select ...

Top 50 recent answers are included