Sample Header Ad - 728x90

Merge sub-queries to a single query

0 votes
1 answer
1278 views
I am trying to merge the nested **MYSQL** queries into one First of all I fire this query select names , city , category from names_data group by names , city ,category ; this produces a result of ~28000 from master names_data table now for each entry in the result I fire this query inside a python loop select date, name, city , old_mul, new_mul from name_changes where name=' + name + ' and city=' + city + """' order by date desc limit 2 ; I just want the last 2 records date wise for each name and city combination from this name_changes table I have tried few JOINS and groups operation but was not able to achieve what this Right Now I have 1 + 28000*1 queries **I want to reduce the queries** Help is really appreciated :) p.s. the tables are different
Asked by Beginner (1 rep)
Jul 7, 2016, 07:30 AM
Last activity: Aug 10, 2025, 06:00 PM