-- --------------------------------------------------------
-- Complete Bangladesh Thanas (Upazilas) Data
-- All Thanas for All 64 Districts
-- --------------------------------------------------------

-- ============================================================
-- DHAKA DIVISION THANAS
-- ============================================================

-- Dhaka District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Dhanmondi' as name, 'DHN' as code UNION ALL
    SELECT 'Gulshan', 'GLS' UNION ALL
    SELECT 'Banani', 'BNN' UNION ALL
    SELECT 'Uttara', 'UTR' UNION ALL
    SELECT 'Motijheel', 'MTJ' UNION ALL
    SELECT 'Ramna', 'RMN' UNION ALL
    SELECT 'Tejgaon', 'TJG' UNION ALL
    SELECT 'Wari', 'WRI' UNION ALL
    SELECT 'Lalbagh', 'LBG' UNION ALL
    SELECT 'Kotwali', 'KTW' UNION ALL
    SELECT 'Sutrapur', 'STR' UNION ALL
    SELECT 'Sabujbagh', 'SBJ' UNION ALL
    SELECT 'Cantonment', 'CNT' UNION ALL
    SELECT 'Demra', 'DMR' UNION ALL
    SELECT 'Dohar', 'DHR' UNION ALL
    SELECT 'Dhamrai', 'DMR' UNION ALL
    SELECT 'Keraniganj', 'KRG' UNION ALL
    SELECT 'Nawabganj', 'NWB' UNION ALL
    SELECT 'Savar', 'SVR'
) as t
WHERE d.name = 'Dhaka' AND dv.name = 'Dhaka';

-- Gazipur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Gazipur Sadar' as name, 'GZS' as code UNION ALL
    SELECT 'Kaliakair', 'KLK' UNION ALL
    SELECT 'Kapasia', 'KPS' UNION ALL
    SELECT 'Sreepur', 'SRP' UNION ALL
    SELECT 'Kaliganj', 'KLG'
) as t
WHERE d.name = 'Gazipur' AND dv.name = 'Dhaka';

-- Narayanganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Narayanganj Sadar' as name, 'NRS' as code UNION ALL
    SELECT 'Bandar', 'BDR' UNION ALL
    SELECT 'Rupganj', 'RPG' UNION ALL
    SELECT 'Sonargaon', 'SNG' UNION ALL
    SELECT 'Araihazar', 'ARH'
) as t
WHERE d.name = 'Narayanganj' AND dv.name = 'Dhaka';

-- Tangail District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Tangail Sadar' as name, 'TGS' as code UNION ALL
    SELECT 'Basail', 'BSL' UNION ALL
    SELECT 'Bhuapur', 'BHP' UNION ALL
    SELECT 'Delduar', 'DLD' UNION ALL
    SELECT 'Dhanbari', 'DHB' UNION ALL
    SELECT 'Ghatail', 'GTL' UNION ALL
    SELECT 'Gopalpur', 'GPP' UNION ALL
    SELECT 'Kalihati', 'KLH' UNION ALL
    SELECT 'Madhupur', 'MDP' UNION ALL
    SELECT 'Mirzapur', 'MRZ' UNION ALL
    SELECT 'Nagarpur', 'NGP' UNION ALL
    SELECT 'Sakhipur', 'SKP'
) as t
WHERE d.name = 'Tangail' AND dv.name = 'Dhaka';

-- Kishoreganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Kishoreganj Sadar' as name, 'KSG' as code UNION ALL
    SELECT 'Austagram', 'AST' UNION ALL
    SELECT 'Bajitpur', 'BJP' UNION ALL
    SELECT 'Bhairab', 'BHR' UNION ALL
    SELECT 'Hossainpur', 'HSP' UNION ALL
    SELECT 'Itna', 'ITN' UNION ALL
    SELECT 'Karimganj', 'KRG' UNION ALL
    SELECT 'Katiadi', 'KTD' UNION ALL
    SELECT 'Kuliarchar', 'KLC' UNION ALL
    SELECT 'Mithamain', 'MTM' UNION ALL
    SELECT 'Nikli', 'NKL' UNION ALL
    SELECT 'Pakundia', 'PKD' UNION ALL
    SELECT 'Tarail', 'TRL'
) as t
WHERE d.name = 'Kishoreganj' AND dv.name = 'Dhaka';

-- Manikganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Manikganj Sadar' as name, 'MKS' as code UNION ALL
    SELECT 'Daulatpur', 'DLP' UNION ALL
    SELECT 'Ghior', 'GHR' UNION ALL
    SELECT 'Harirampur', 'HRP' UNION ALL
    SELECT 'Saturia', 'STR' UNION ALL
    SELECT 'Shibalaya', 'SBL' UNION ALL
    SELECT 'Singair', 'SGR'
) as t
WHERE d.name = 'Manikganj' AND dv.name = 'Dhaka';

-- Munshiganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Munshiganj Sadar' as name, 'MNS' as code UNION ALL
    SELECT 'Gazaria', 'GZR' UNION ALL
    SELECT 'Lohajang', 'LHG' UNION ALL
    SELECT 'Sirajdikhan', 'SRD' UNION ALL
    SELECT 'Sreenagar', 'SRN' UNION ALL
    SELECT 'Tongibari', 'TGB'
) as t
WHERE d.name = 'Munshiganj' AND dv.name = 'Dhaka';

-- Narsingdi District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Narsingdi Sadar' as name, 'NSS' as code UNION ALL
    SELECT 'Belabo', 'BLB' UNION ALL
    SELECT 'Monohardi', 'MNH' UNION ALL
    SELECT 'Palash', 'PLS' UNION ALL
    SELECT 'Raipura', 'RPR' UNION ALL
    SELECT 'Shibpur', 'SBP'
) as t
WHERE d.name = 'Narsingdi' AND dv.name = 'Dhaka';

-- Faridpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Faridpur Sadar' as name, 'FRS' as code UNION ALL
    SELECT 'Alfadanga', 'AFD' UNION ALL
    SELECT 'Bhanga', 'BHG' UNION ALL
    SELECT 'Boalmari', 'BLM' UNION ALL
    SELECT 'Charbhadrasan', 'CBD' UNION ALL
    SELECT 'Madhukhali', 'MDK' UNION ALL
    SELECT 'Nagarkanda', 'NGK' UNION ALL
    SELECT 'Sadarpur', 'SDP'
) as t
WHERE d.name = 'Faridpur' AND dv.name = 'Dhaka';

-- Gopalganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Gopalganj Sadar' as name, 'GPS' as code UNION ALL
    SELECT 'Kashiani', 'KSH' UNION ALL
    SELECT 'Kotalipara', 'KTP' UNION ALL
    SELECT 'Muksudpur', 'MKS' UNION ALL
    SELECT 'Tungipara', 'TGP'
) as t
WHERE d.name = 'Gopalganj' AND dv.name = 'Dhaka';

-- Madaripur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Madaripur Sadar' as name, 'MDS' as code UNION ALL
    SELECT 'Kalkini', 'KLK' UNION ALL
    SELECT 'Rajoir', 'RJR' UNION ALL
    SELECT 'Shibchar', 'SBC'
) as t
WHERE d.name = 'Madaripur' AND dv.name = 'Dhaka';

-- Rajbari District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Rajbari Sadar' as name, 'RJS' as code UNION ALL
    SELECT 'Baliakandi', 'BLK' UNION ALL
    SELECT 'Goalandaghat', 'GLD' UNION ALL
    SELECT 'Pangsha', 'PGS'
) as t
WHERE d.name = 'Rajbari' AND dv.name = 'Dhaka';

-- Shariatpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Shariatpur Sadar' as name, 'SRS' as code UNION ALL
    SELECT 'Bhedarganj', 'BDG' UNION ALL
    SELECT 'Damudya', 'DMY' UNION ALL
    SELECT 'Gosairhat', 'GSH' UNION ALL
    SELECT 'Naria', 'NRA' UNION ALL
    SELECT 'Zajira', 'ZJR'
) as t
WHERE d.name = 'Shariatpur' AND dv.name = 'Dhaka';

-- ============================================================
-- CHITTAGONG DIVISION THANAS
-- ============================================================

-- Chittagong District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Chittagong Sadar' as name, 'CTS' as code UNION ALL
    SELECT 'Hathazari', 'HTZ' UNION ALL
    SELECT 'Raujan', 'RJU' UNION ALL
    SELECT 'Fatikchhari', 'FTC' UNION ALL
    SELECT 'Sandwip', 'SDW' UNION ALL
    SELECT 'Sitakunda', 'STK' UNION ALL
    SELECT 'Mirsharai', 'MRS' UNION ALL
    SELECT 'Patiya', 'PTY' UNION ALL
    SELECT 'Banshkhali', 'BSK' UNION ALL
    SELECT 'Boalkhali', 'BKL' UNION ALL
    SELECT 'Anwara', 'ANW' UNION ALL
    SELECT 'Chandanaish', 'CDN' UNION ALL
    SELECT 'Satkania', 'STK' UNION ALL
    SELECT 'Lohagara', 'LHG'
) as t
WHERE d.name = 'Chittagong' AND dv.name = 'Chittagong';

-- Comilla District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Comilla Sadar' as name, 'CMS' as code UNION ALL
    SELECT 'Barura', 'BRR' UNION ALL
    SELECT 'Brahmanpara', 'BRM' UNION ALL
    SELECT 'Burichang', 'BRC' UNION ALL
    SELECT 'Chandina', 'CDN' UNION ALL
    SELECT 'Chauddagram', 'CDG' UNION ALL
    SELECT 'Daudkandi', 'DDK' UNION ALL
    SELECT 'Debidwar', 'DBD' UNION ALL
    SELECT 'Homna', 'HMN' UNION ALL
    SELECT 'Laksam', 'LKM' UNION ALL
    SELECT 'Monohargonj', 'MNG' UNION ALL
    SELECT 'Meghna', 'MGH' UNION ALL
    SELECT 'Muradnagar', 'MRD' UNION ALL
    SELECT 'Nangalkot', 'NGK' UNION ALL
    SELECT 'Titas', 'TTS'
) as t
WHERE d.name = 'Comilla' AND dv.name = 'Chittagong';

-- Cox's Bazar District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Cox\'s Bazar Sadar' as name, 'CXS' as code UNION ALL
    SELECT 'Chakaria', 'CKR' UNION ALL
    SELECT 'Kutubdia', 'KTB' UNION ALL
    SELECT 'Maheshkhali', 'MHK' UNION ALL
    SELECT 'Pekua', 'PKU' UNION ALL
    SELECT 'Ramu', 'RMU' UNION ALL
    SELECT 'Teknaf', 'TKF' UNION ALL
    SELECT 'Ukhia', 'UKH'
) as t
WHERE d.name = 'Cox\'s Bazar' AND dv.name = 'Chittagong';

-- Feni District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Feni Sadar' as name, 'FNS' as code UNION ALL
    SELECT 'Chhagalnaiya', 'CHG' UNION ALL
    SELECT 'Daganbhuiyan', 'DGB' UNION ALL
    SELECT 'Parshuram', 'PSR' UNION ALL
    SELECT 'Sonagazi', 'SNG'
) as t
WHERE d.name = 'Feni' AND dv.name = 'Chittagong';

-- Lakshmipur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Lakshmipur Sadar' as name, 'LKS' as code UNION ALL
    SELECT 'Raipur', 'RPR' UNION ALL
    SELECT 'Ramganj', 'RMG' UNION ALL
    SELECT 'Ramgati', 'RMT' UNION ALL
    SELECT 'Kamalnagar', 'KML'
) as t
WHERE d.name = 'Lakshmipur' AND dv.name = 'Chittagong';

-- Noakhali District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Noakhali Sadar' as name, 'NKS' as code UNION ALL
    SELECT 'Begumganj', 'BGM' UNION ALL
    SELECT 'Chatkhil', 'CTK' UNION ALL
    SELECT 'Companiganj', 'CPG' UNION ALL
    SELECT 'Hatiya', 'HTY' UNION ALL
    SELECT 'Kabirhat', 'KBH' UNION ALL
    SELECT 'Senbagh', 'SNB' UNION ALL
    SELECT 'Sonaimuri', 'SNM' UNION ALL
    SELECT 'Subarnachar', 'SBC'
) as t
WHERE d.name = 'Noakhali' AND dv.name = 'Chittagong';

-- Chandpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Chandpur Sadar' as name, 'CDS' as code UNION ALL
    SELECT 'Faridganj', 'FDG' UNION ALL
    SELECT 'Haimchar', 'HMC' UNION ALL
    SELECT 'Hajiganj', 'HJG' UNION ALL
    SELECT 'Kachua', 'KCH' UNION ALL
    SELECT 'Matlab Dakshin', 'MLD' UNION ALL
    SELECT 'Matlab Uttar', 'MLU' UNION ALL
    SELECT 'Shahrasti', 'SHS'
) as t
WHERE d.name = 'Chandpur' AND dv.name = 'Chittagong';

-- Brahmanbaria District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Brahmanbaria Sadar' as name, 'BRS' as code UNION ALL
    SELECT 'Ashuganj', 'ASG' UNION ALL
    SELECT 'Bancharampur', 'BCP' UNION ALL
    SELECT 'Bijoynagar', 'BJN' UNION ALL
    SELECT 'Kasba', 'KSB' UNION ALL
    SELECT 'Nabinagar', 'NBN' UNION ALL
    SELECT 'Nasirnagar', 'NSN' UNION ALL
    SELECT 'Sarail', 'SRL'
) as t
WHERE d.name = 'Brahmanbaria' AND dv.name = 'Chittagong';

-- Bandarban District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Bandarban Sadar' as name, 'BDS' as code UNION ALL
    SELECT 'Alikadam', 'AKD' UNION ALL
    SELECT 'Lama', 'LMA' UNION ALL
    SELECT 'Naikhongchhari', 'NKC' UNION ALL
    SELECT 'Rowangchhari', 'RWC' UNION ALL
    SELECT 'Ruma', 'RMA' UNION ALL
    SELECT 'Thanchi', 'THC'
) as t
WHERE d.name = 'Bandarban' AND dv.name = 'Chittagong';

-- Rangamati District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Rangamati Sadar' as name, 'RMS' as code UNION ALL
    SELECT 'Bagaichhari', 'BGC' UNION ALL
    SELECT 'Barkal', 'BKL' UNION ALL
    SELECT 'Jurachhari', 'JRC' UNION ALL
    SELECT 'Kaptai', 'KPT' UNION ALL
    SELECT 'Kawkhali', 'KWK' UNION ALL
    SELECT 'Langadu', 'LGD' UNION ALL
    SELECT 'Naniarchar', 'NNC' UNION ALL
    SELECT 'Rajasthali', 'RJS'
) as t
WHERE d.name = 'Rangamati' AND dv.name = 'Chittagong';

-- Khagrachhari District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Khagrachhari Sadar' as name, 'KGS' as code UNION ALL
    SELECT 'Dighinala', 'DGL' UNION ALL
    SELECT 'Lakshmichhari', 'LMC' UNION ALL
    SELECT 'Mahalchhari', 'MHC' UNION ALL
    SELECT 'Manikchhari', 'MKC' UNION ALL
    SELECT 'Matiranga', 'MTR' UNION ALL
    SELECT 'Panchhari', 'PCH' UNION ALL
    SELECT 'Ramgarh', 'RMG'
) as t
WHERE d.name = 'Khagrachhari' AND dv.name = 'Chittagong';

-- ============================================================
-- RAJSHAHI DIVISION THANAS
-- ============================================================

-- Rajshahi District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Rajshahi Sadar' as name, 'RJS' as code UNION ALL
    SELECT 'Bagha', 'BGH' UNION ALL
    SELECT 'Bagmara', 'BGM' UNION ALL
    SELECT 'Charghat', 'CGT' UNION ALL
    SELECT 'Durgapur', 'DRG' UNION ALL
    SELECT 'Godagari', 'GDG' UNION ALL
    SELECT 'Mohanpur', 'MHP' UNION ALL
    SELECT 'Paba', 'PBA' UNION ALL
    SELECT 'Puthia', 'PTH' UNION ALL
    SELECT 'Tanore', 'TNR'
) as t
WHERE d.name = 'Rajshahi' AND dv.name = 'Rajshahi';

-- Bogra District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Bogra Sadar' as name, 'BGS' as code UNION ALL
    SELECT 'Adamdighi', 'ADG' UNION ALL
    SELECT 'Dhunat', 'DHT' UNION ALL
    SELECT 'Dhupchanchia', 'DPC' UNION ALL
    SELECT 'Gabtali', 'GBT' UNION ALL
    SELECT 'Kahaloo', 'KHL' UNION ALL
    SELECT 'Nandigram', 'NDG' UNION ALL
    SELECT 'Sariakandi', 'SRK' UNION ALL
    SELECT 'Shajahanpur', 'SJP' UNION ALL
    SELECT 'Sherpur', 'SHP' UNION ALL
    SELECT 'Shibganj', 'SBG' UNION ALL
    SELECT 'Sonatala', 'SNT'
) as t
WHERE d.name = 'Bogra' AND dv.name = 'Rajshahi';

-- Joypurhat District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Joypurhat Sadar' as name, 'JPS' as code UNION ALL
    SELECT 'Akkelpur', 'AKP' UNION ALL
    SELECT 'Kalai', 'KLI' UNION ALL
    SELECT 'Khetlal', 'KTL' UNION ALL
    SELECT 'Panchbibi', 'PCB'
) as t
WHERE d.name = 'Joypurhat' AND dv.name = 'Rajshahi';

-- Naogaon District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Naogaon Sadar' as name, 'NGS' as code UNION ALL
    SELECT 'Atrai', 'ATR' UNION ALL
    SELECT 'Badalgachhi', 'BDG' UNION ALL
    SELECT 'Dhamoirhat', 'DMR' UNION ALL
    SELECT 'Manda', 'MND' UNION ALL
    SELECT 'Mahadebpur', 'MHD' UNION ALL
    SELECT 'Niamatpur', 'NMP' UNION ALL
    SELECT 'Patnitala', 'PTN' UNION ALL
    SELECT 'Porsha', 'PRS' UNION ALL
    SELECT 'Raninagar', 'RNG' UNION ALL
    SELECT 'Sapahar', 'SPH'
) as t
WHERE d.name = 'Naogaon' AND dv.name = 'Rajshahi';

-- Natore District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Natore Sadar' as name, 'NTS' as code UNION ALL
    SELECT 'Bagatipara', 'BGT' UNION ALL
    SELECT 'Baraigram', 'BRG' UNION ALL
    SELECT 'Gurudaspur', 'GRD' UNION ALL
    SELECT 'Lalpur', 'LPR' UNION ALL
    SELECT 'Singra', 'SGR'
) as t
WHERE d.name = 'Natore' AND dv.name = 'Rajshahi';

-- Chapai Nawabganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Chapai Nawabganj Sadar' as name, 'CNS' as code UNION ALL
    SELECT 'Bholahat', 'BHL' UNION ALL
    SELECT 'Gomastapur', 'GMS' UNION ALL
    SELECT 'Nachole', 'NCL' UNION ALL
    SELECT 'Shibganj', 'SBG'
) as t
WHERE d.name = 'Chapai Nawabganj' AND dv.name = 'Rajshahi';

-- Pabna District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Pabna Sadar' as name, 'PBS' as code UNION ALL
    SELECT 'Atgharia', 'ATG' UNION ALL
    SELECT 'Bera', 'BER' UNION ALL
    SELECT 'Bhangura', 'BHG' UNION ALL
    SELECT 'Chatmohar', 'CTM' UNION ALL
    SELECT 'Faridpur', 'FRP' UNION ALL
    SELECT 'Ishwardi', 'ISW' UNION ALL
    SELECT 'Santhia', 'SNT' UNION ALL
    SELECT 'Sujanagar', 'SJG'
) as t
WHERE d.name = 'Pabna' AND dv.name = 'Rajshahi';

-- Sirajganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Sirajganj Sadar' as name, 'SRS' as code UNION ALL
    SELECT 'Belkuchi', 'BLC' UNION ALL
    SELECT 'Chauhali', 'CHL' UNION ALL
    SELECT 'Kamarkhanda', 'KMK' UNION ALL
    SELECT 'Kazipur', 'KZP' UNION ALL
    SELECT 'Raiganj', 'RGN' UNION ALL
    SELECT 'Shahjadpur', 'SJP' UNION ALL
    SELECT 'Tarash', 'TRS' UNION ALL
    SELECT 'Ullahpara', 'ULP'
) as t
WHERE d.name = 'Sirajganj' AND dv.name = 'Rajshahi';

-- ============================================================
-- KHULNA DIVISION THANAS
-- ============================================================

-- Khulna District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Khulna Sadar' as name, 'KLS' as code UNION ALL
    SELECT 'Batiaghata', 'BTG' UNION ALL
    SELECT 'Dacope', 'DCP' UNION ALL
    SELECT 'Dumuria', 'DMR' UNION ALL
    SELECT 'Dighalia', 'DGL' UNION ALL
    SELECT 'Koyra', 'KYR' UNION ALL
    SELECT 'Paikgachha', 'PKG' UNION ALL
    SELECT 'Phultala', 'PHT' UNION ALL
    SELECT 'Rupsa', 'RPS' UNION ALL
    SELECT 'Terokhada', 'TRK'
) as t
WHERE d.name = 'Khulna' AND dv.name = 'Khulna';

-- Jashore District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Jashore Sadar' as name, 'JSS' as code UNION ALL
    SELECT 'Abhaynagar', 'ABN' UNION ALL
    SELECT 'Bagherpara', 'BGP' UNION ALL
    SELECT 'Chaugachha', 'CGC' UNION ALL
    SELECT 'Jhikargacha', 'JKG' UNION ALL
    SELECT 'Keshabpur', 'KSB' UNION ALL
    SELECT 'Manirampur', 'MRP' UNION ALL
    SELECT 'Sharsha', 'SRS'
) as t
WHERE d.name = 'Jashore' AND dv.name = 'Khulna';

-- Bagerhat District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Bagerhat Sadar' as name, 'BHS' as code UNION ALL
    SELECT 'Chitalmari', 'CTM' UNION ALL
    SELECT 'Fakirhat', 'FKH' UNION ALL
    SELECT 'Kachua', 'KCH' UNION ALL
    SELECT 'Mollahat', 'MLH' UNION ALL
    SELECT 'Mongla', 'MGL' UNION ALL
    SELECT 'Morrelganj', 'MRG' UNION ALL
    SELECT 'Rampal', 'RMP' UNION ALL
    SELECT 'Sarankhola', 'SRK'
) as t
WHERE d.name = 'Bagerhat' AND dv.name = 'Khulna';

-- Chuadanga District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Chuadanga Sadar' as name, 'CDS' as code UNION ALL
    SELECT 'Alamdanga', 'AMD' UNION ALL
    SELECT 'Damurhuda', 'DMH' UNION ALL
    SELECT 'Jibannagar', 'JBN'
) as t
WHERE d.name = 'Chuadanga' AND dv.name = 'Khulna';

-- Jhenaidah District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Jhenaidah Sadar' as name, 'JNS' as code UNION ALL
    SELECT 'Harinakunda', 'HRK' UNION ALL
    SELECT 'Kaliganj', 'KLG' UNION ALL
    SELECT 'Kotchandpur', 'KCP' UNION ALL
    SELECT 'Maheshpur', 'MHP' UNION ALL
    SELECT 'Shailkupa', 'SLK'
) as t
WHERE d.name = 'Jhenaidah' AND dv.name = 'Khulna';

-- Kushtia District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Kushtia Sadar' as name, 'KTS' as code UNION ALL
    SELECT 'Bheramara', 'BHR' UNION ALL
    SELECT 'Daulatpur', 'DLP' UNION ALL
    SELECT 'Khoksa', 'KHK' UNION ALL
    SELECT 'Kumarkhali', 'KMK' UNION ALL
    SELECT 'Mirpur', 'MRP'
) as t
WHERE d.name = 'Kushtia' AND dv.name = 'Khulna';

-- Magura District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Magura Sadar' as name, 'MGS' as code UNION ALL
    SELECT 'Mohammadpur', 'MHD' UNION ALL
    SELECT 'Shalikha', 'SLK' UNION ALL
    SELECT 'Sreepur', 'SRP'
) as t
WHERE d.name = 'Magura' AND dv.name = 'Khulna';

-- Meherpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Meherpur Sadar' as name, 'MHS' as code UNION ALL
    SELECT 'Gangni', 'GNG' UNION ALL
    SELECT 'Mujibnagar', 'MJN'
) as t
WHERE d.name = 'Meherpur' AND dv.name = 'Khulna';

-- Narail District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Narail Sadar' as name, 'NRS' as code UNION ALL
    SELECT 'Kalia', 'KLA' UNION ALL
    SELECT 'Lohagara', 'LHG'
) as t
WHERE d.name = 'Narail' AND dv.name = 'Khulna';

-- Satkhira District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Satkhira Sadar' as name, 'SKS' as code UNION ALL
    SELECT 'Assasuni', 'ASN' UNION ALL
    SELECT 'Debhata', 'DBT' UNION ALL
    SELECT 'Kalaroa', 'KLR' UNION ALL
    SELECT 'Kaliganj', 'KLG' UNION ALL
    SELECT 'Shyamnagar', 'SYN' UNION ALL
    SELECT 'Tala', 'TLA'
) as t
WHERE d.name = 'Satkhira' AND dv.name = 'Khulna';

-- ============================================================
-- BARISAL DIVISION THANAS
-- ============================================================

-- Barisal District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Barisal Sadar' as name, 'BRS' as code UNION ALL
    SELECT 'Agailjhara', 'AGJ' UNION ALL
    SELECT 'Babuganj', 'BBG' UNION ALL
    SELECT 'Bakerganj', 'BKG' UNION ALL
    SELECT 'Banaripara', 'BNP' UNION ALL
    SELECT 'Gaurnadi', 'GRD' UNION ALL
    SELECT 'Hizla', 'HZL' UNION ALL
    SELECT 'Mehendiganj', 'MHD' UNION ALL
    SELECT 'Muladi', 'MLD' UNION ALL
    SELECT 'Wazirpur', 'WZP'
) as t
WHERE d.name = 'Barisal' AND dv.name = 'Barisal';

-- Barguna District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Barguna Sadar' as name, 'BGS' as code UNION ALL
    SELECT 'Amtali', 'AMT' UNION ALL
    SELECT 'Bamna', 'BMN' UNION ALL
    SELECT 'Betagi', 'BTG' UNION ALL
    SELECT 'Patharghata', 'PTG'
) as t
WHERE d.name = 'Barguna' AND dv.name = 'Barisal';

-- Bhola District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Bhola Sadar' as name, 'BLS' as code UNION ALL
    SELECT 'Borhanuddin', 'BRH' UNION ALL
    SELECT 'Char Fasson', 'CFS' UNION ALL
    SELECT 'Daulatkhan', 'DLK' UNION ALL
    SELECT 'Lalmohan', 'LMH' UNION ALL
    SELECT 'Manpura', 'MPR' UNION ALL
    SELECT 'Tazumuddin', 'TZM'
) as t
WHERE d.name = 'Bhola' AND dv.name = 'Barisal';

-- Jhalokati District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Jhalokati Sadar' as name, 'JHS' as code UNION ALL
    SELECT 'Kathalia', 'KTH' UNION ALL
    SELECT 'Nalchity', 'NLC' UNION ALL
    SELECT 'Rajapur', 'RJP'
) as t
WHERE d.name = 'Jhalokati' AND dv.name = 'Barisal';

-- Patuakhali District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Patuakhali Sadar' as name, 'PTS' as code UNION ALL
    SELECT 'Bauphal', 'BPL' UNION ALL
    SELECT 'Dashmina', 'DSM' UNION ALL
    SELECT 'Dumki', 'DMK' UNION ALL
    SELECT 'Galachipa', 'GLC' UNION ALL
    SELECT 'Kalapara', 'KLP' UNION ALL
    SELECT 'Mirzaganj', 'MRZ' UNION ALL
    SELECT 'Rangabali', 'RGB'
) as t
WHERE d.name = 'Patuakhali' AND dv.name = 'Barisal';

-- Pirojpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Pirojpur Sadar' as name, 'PRS' as code UNION ALL
    SELECT 'Bhandaria', 'BHD' UNION ALL
    SELECT 'Kaukhali', 'KUK' UNION ALL
    SELECT 'Mathbaria', 'MTB' UNION ALL
    SELECT 'Nazirpur', 'NZP' UNION ALL
    SELECT 'Nesarabad', 'NSB' UNION ALL
    SELECT 'Zianagar', 'ZNG'
) as t
WHERE d.name = 'Pirojpur' AND dv.name = 'Barisal';

-- ============================================================
-- SYLHET DIVISION THANAS
-- ============================================================

-- Sylhet District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Sylhet Sadar' as name, 'SLS' as code UNION ALL
    SELECT 'Balaganj', 'BLG' UNION ALL
    SELECT 'Beanibazar', 'BNB' UNION ALL
    SELECT 'Bishwanath', 'BSW' UNION ALL
    SELECT 'Fenchuganj', 'FNG' UNION ALL
    SELECT 'Golapganj', 'GLP' UNION ALL
    SELECT 'Gowainghat', 'GWG' UNION ALL
    SELECT 'Jaintiapur', 'JNP' UNION ALL
    SELECT 'Kanaighat', 'KNG' UNION ALL
    SELECT 'Osmani Nagar', 'OSN' UNION ALL
    SELECT 'Zakiganj', 'ZKG'
) as t
WHERE d.name = 'Sylhet' AND dv.name = 'Sylhet';

-- Habiganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Habiganj Sadar' as name, 'HBS' as code UNION ALL
    SELECT 'Ajmiriganj', 'AJM' UNION ALL
    SELECT 'Bahubal', 'BHB' UNION ALL
    SELECT 'Baniyachong', 'BNC' UNION ALL
    SELECT 'Chunarughat', 'CNR' UNION ALL
    SELECT 'Lakhai', 'LKH' UNION ALL
    SELECT 'Madhabpur', 'MDB' UNION ALL
    SELECT 'Nabiganj', 'NBG'
) as t
WHERE d.name = 'Habiganj' AND dv.name = 'Sylhet';

-- Moulvibazar District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Moulvibazar Sadar' as name, 'MLS' as code UNION ALL
    SELECT 'Barlekha', 'BLK' UNION ALL
    SELECT 'Juri', 'JRI' UNION ALL
    SELECT 'Kamalganj', 'KML' UNION ALL
    SELECT 'Kulaura', 'KLR' UNION ALL
    SELECT 'Rajnagar', 'RJN' UNION ALL
    SELECT 'Sreemangal', 'SRM'
) as t
WHERE d.name = 'Moulvibazar' AND dv.name = 'Sylhet';

-- Sunamganj District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Sunamganj Sadar' as name, 'SNS' as code UNION ALL
    SELECT 'Bishwamvarpur', 'BSW' UNION ALL
    SELECT 'Chhatak', 'CHT' UNION ALL
    SELECT 'Derai', 'DRY' UNION ALL
    SELECT 'Dharampasha', 'DHP' UNION ALL
    SELECT 'Dowarabazar', 'DWB' UNION ALL
    SELECT 'Jagannathpur', 'JGN' UNION ALL
    SELECT 'Jamalganj', 'JML' UNION ALL
    SELECT 'Sulla', 'SLL' UNION ALL
    SELECT 'Tahirpur', 'THP'
) as t
WHERE d.name = 'Sunamganj' AND dv.name = 'Sylhet';

-- ============================================================
-- RANGPUR DIVISION THANAS
-- ============================================================

-- Rangpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Rangpur Sadar' as name, 'RPS' as code UNION ALL
    SELECT 'Badarganj', 'BDG' UNION ALL
    SELECT 'Gangachara', 'GGC' UNION ALL
    SELECT 'Kaunia', 'KNA' UNION ALL
    SELECT 'Mithapukur', 'MTP' UNION ALL
    SELECT 'Pirgacha', 'PRG' UNION ALL
    SELECT 'Pirganj', 'PRJ' UNION ALL
    SELECT 'Taraganj', 'TRG'
) as t
WHERE d.name = 'Rangpur' AND dv.name = 'Rangpur';

-- Dinajpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Dinajpur Sadar' as name, 'DNS' as code UNION ALL
    SELECT 'Birampur', 'BRM' UNION ALL
    SELECT 'Birganj', 'BRG' UNION ALL
    SELECT 'Biral', 'BRL' UNION ALL
    SELECT 'Bochaganj', 'BCG' UNION ALL
    SELECT 'Chirirbandar', 'CRB' UNION ALL
    SELECT 'Fulbari', 'FLB' UNION ALL
    SELECT 'Ghoraghat', 'GRH' UNION ALL
    SELECT 'Hakimpur', 'HKP' UNION ALL
    SELECT 'Kaharole', 'KHR' UNION ALL
    SELECT 'Khansama', 'KNS' UNION ALL
    SELECT 'Nawabganj', 'NWB' UNION ALL
    SELECT 'Parbatipur', 'PBT'
) as t
WHERE d.name = 'Dinajpur' AND dv.name = 'Rangpur';

-- Gaibandha District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Gaibandha Sadar' as name, 'GBS' as code UNION ALL
    SELECT 'Fulchhari', 'FCH' UNION ALL
    SELECT 'Gobindaganj', 'GBG' UNION ALL
    SELECT 'Palashbari', 'PLB' UNION ALL
    SELECT 'Sadullapur', 'SDL' UNION ALL
    SELECT 'Saghata', 'SGT' UNION ALL
    SELECT 'Sundarganj', 'SDG'
) as t
WHERE d.name = 'Gaibandha' AND dv.name = 'Rangpur';

-- Kurigram District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Kurigram Sadar' as name, 'KRS' as code UNION ALL
    SELECT 'Bhurungamari', 'BHR' UNION ALL
    SELECT 'Char Rajibpur', 'CRJ' UNION ALL
    SELECT 'Chilmari', 'CLM' UNION ALL
    SELECT 'Phulbari', 'PLB' UNION ALL
    SELECT 'Nageshwari', 'NGS' UNION ALL
    SELECT 'Rajarhat', 'RJR' UNION ALL
    SELECT 'Raomari', 'RMR' UNION ALL
    SELECT 'Ulipur', 'ULP'
) as t
WHERE d.name = 'Kurigram' AND dv.name = 'Rangpur';

-- Lalmonirhat District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Lalmonirhat Sadar' as name, 'LMS' as code UNION ALL
    SELECT 'Aditmari', 'ADT' UNION ALL
    SELECT 'Hatibandha', 'HTB' UNION ALL
    SELECT 'Kaliganj', 'KLG' UNION ALL
    SELECT 'Patgram', 'PTG'
) as t
WHERE d.name = 'Lalmonirhat' AND dv.name = 'Rangpur';

-- Nilphamari District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Nilphamari Sadar' as name, 'NPS' as code UNION ALL
    SELECT 'Dimla', 'DML' UNION ALL
    SELECT 'Domar', 'DMR' UNION ALL
    SELECT 'Jaldhaka', 'JLD' UNION ALL
    SELECT 'Kishoreganj', 'KSG' UNION ALL
    SELECT 'Saidpur', 'SDP'
) as t
WHERE d.name = 'Nilphamari' AND dv.name = 'Rangpur';

-- Panchagarh District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Panchagarh Sadar' as name, 'PCS' as code UNION ALL
    SELECT 'Atwari', 'ATW' UNION ALL
    SELECT 'Boda', 'BDA' UNION ALL
    SELECT 'Debiganj', 'DBG' UNION ALL
    SELECT 'Tetulia', 'TTL'
) as t
WHERE d.name = 'Panchagarh' AND dv.name = 'Rangpur';

-- Thakurgaon District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Thakurgaon Sadar' as name, 'TKS' as code UNION ALL
    SELECT 'Baliadangi', 'BLD' UNION ALL
    SELECT 'Haripur', 'HRP' UNION ALL
    SELECT 'Pirganj', 'PRJ' UNION ALL
    SELECT 'Ranisankail', 'RNS'
) as t
WHERE d.name = 'Thakurgaon' AND dv.name = 'Rangpur';

-- ============================================================
-- MYMENSINGH DIVISION THANAS
-- ============================================================

-- Mymensingh District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Mymensingh Sadar' as name, 'MYS' as code UNION ALL
    SELECT 'Bhaluka', 'BLK' UNION ALL
    SELECT 'Dhobaura', 'DHB' UNION ALL
    SELECT 'Fulbaria', 'FLB' UNION ALL
    SELECT 'Gaffargaon', 'GFG' UNION ALL
    SELECT 'Gauripur', 'GRP' UNION ALL
    SELECT 'Haluaghat', 'HLG' UNION ALL
    SELECT 'Ishwarganj', 'ISG' UNION ALL
    SELECT 'Muktagachha', 'MKG' UNION ALL
    SELECT 'Nandail', 'NDL' UNION ALL
    SELECT 'Phulpur', 'PHP' UNION ALL
    SELECT 'Tarakanda', 'TRK'
) as t
WHERE d.name = 'Mymensingh' AND dv.name = 'Mymensingh';

-- Jamalpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Jamalpur Sadar' as name, 'JMS' as code UNION ALL
    SELECT 'Baksiganj', 'BKS' UNION ALL
    SELECT 'Dewanganj', 'DWG' UNION ALL
    SELECT 'Islampur', 'ISL' UNION ALL
    SELECT 'Madarganj', 'MDG' UNION ALL
    SELECT 'Melandaha', 'MLD' UNION ALL
    SELECT 'Sarishabari', 'SRS'
) as t
WHERE d.name = 'Jamalpur' AND dv.name = 'Mymensingh';

-- Netrokona District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Netrokona Sadar' as name, 'NTS' as code UNION ALL
    SELECT 'Atpara', 'ATP' UNION ALL
    SELECT 'Barhatta', 'BHT' UNION ALL
    SELECT 'Durgapur', 'DRG' UNION ALL
    SELECT 'Khaliajuri', 'KLJ' UNION ALL
    SELECT 'Kalmakanda', 'KLM' UNION ALL
    SELECT 'Kendua', 'KND' UNION ALL
    SELECT 'Madan', 'MDN' UNION ALL
    SELECT 'Mohanganj', 'MHG' UNION ALL
    SELECT 'Purbadhala', 'PRB'
) as t
WHERE d.name = 'Netrokona' AND dv.name = 'Mymensingh';

-- Sherpur District Thanas
INSERT IGNORE INTO `thanas` (`district_id`, `name`, `code`, `is_active`) 
SELECT d.id, t.name, t.code, 1
FROM districts d
JOIN divisions dv ON d.division_id = dv.id
CROSS JOIN (
    SELECT 'Sherpur Sadar' as name, 'SPS' as code UNION ALL
    SELECT 'Jhenaigati', 'JNG' UNION ALL
    SELECT 'Nakla', 'NKL' UNION ALL
    SELECT 'Nalitabari', 'NLT' UNION ALL
    SELECT 'Sreebardi', 'SRB'
) as t
WHERE d.name = 'Sherpur' AND dv.name = 'Mymensingh';

