SELECT fetch_data.year,
fetch_data.month,
fetch_data.week,
fetch_data.day,
fetch_data.minute,
fetch_data.full_date,
fetch_data.category_id,
fetch_data.town_id,
fetch_data.company_id,
fetch_data.url,
fetch_data.data,
fetch_data.front_url,
fetch_data.pattern_id,
fetch_data.swedish_church_id,
fetch_data.sub_town_id,
fetch_data.img_url,
company.company,
category.category,
town.town,
town.country,
geonames_town.latitude,
geonames_town.longitude,
geonames_nearby.address,
geonames_nearby.id
FROM fetch_data
LEFT JOIN company ON fetch_data.company_id=company.company_id
LEFT JOIN category ON fetch_data.category_id=category.category_id
LEFT JOIN town ON town.town_id=fetch_data.town_id
LEFT JOIN geonames_town ON geonames_town.town_id=fetch_data.town_id
LEFT JOIN geonames_nearby ON geonames_nearby.id=fetch_data.sub_town_id WHERE ((year=2025 AND (town.town_id > 0) AND (month=01 AND day=0 OR week=04 OR (month=01 AND day=22))) OR (year=0 AND (town.town_id > 0))) AND country=0 ORDER BY fetch_data.full_date,company.company_sortorder DESC