snippet/vault
🔎
All Snippets
3 snippets পাওয়া গেছে
teacher_information
INSERT INTO akfhhighschool_emsdb.teachers ( 
    designation, name, joining_date, birthdate, mpo_date,
    index_no, email, phone, nid, photo, edu_qualification, status
)
SELECT
    degination, teacher_name, joining_date, birth_day, mpo_date,
    NULL, email, mobile, nid, picture, education_status, status
FROM akfhhighschool_websitedb.teacher_information;

UPDATE `teachers` SET `type` = 'Teacher' WHERE  1;
UPDATE teachers
SET teacher_code = CONCAT('25', LPAD(id, 2, '0'));
-- Notice Migration
INSERT INTO akfhhighschool_emsdb.notices (title, description, file, created_at, updated_at)
SELECT
    title,
    title, -- description এও title বসানো হলো
    file_name,
    date,
    date
FROM akfhhighschool_websitedb.upload_file
WHERE 1 ;
-- Exam Result Migration
INSERT INTO akfhhighschool_emsdb.exam_result (`date`, `title`, `file`, `status`, `created_at`, `updated_at`)
SELECT
    date,
    title,
    file_name,
    1,              -- status ফিক্সড 1
    date,
    NOW()
FROM akfhhighschool_websitedb.upload_file
WHERE 1;
-- Executive Council Migration
INSERT INTO akfhhighschool_emsdb.excutive_council (id, name, designation, category)
SELECT id, name, designation, details
FROM akfhhighschool_websitedb.excutive_council;
-- This will silently install the 64-bit Access Database Engine without checking for conflicting Office versions.
cd C:\Users\USER\Downloads
AccessDatabaseEngine_x64.exe /quiet
-- Open Port Check Tool -- Use this tool to check if a specific port is open on your server or local machine.
https://canyouseeme.org/
-- user_id এবং punch_time মিল থাকা ডুপ্লিকেট ডাটার মধ্যে যেটি পরে এন্ট্রি হয়েছে (ID বড়) সেটি ডিলিট করতে
DELETE t1
FROM attendances t1
INNER JOIN attendances t2 
WHERE 
    t1.id < t2.id AND 
    t1.user_id = t2.user_id AND 
    t1.punch_time = t2.punch_time;
-- ভবিষ্যতে যেন একই সময়ে একই ইউজারের ডুপ্লিকেট পাঞ্চ এন্ট্রি না হতে পারে, সেজন্য ইউনিক ইনডেক্স যোগ করতে
ALTER TABLE attendances ADD UNIQUE unique_attendance (user_id, punch_time);
-- গ্রুপ বাই (GROUP BY) ও সাবকোয়েরি ব্যবহার করে সবচেয়ে প্রথম এন্ট্রি (MIN id) বাদে বাকি ডুপ্লিকেট রেকর্ডগুলো মুছে ফেলতে
DELETE a
FROM attendances a
JOIN (
    SELECT user_id, punch_time, MIN(id) AS min_id
    FROM attendances
    GROUP BY user_id, punch_time
    HAVING COUNT(*) > 1
) b ON a.user_id = b.user_id AND a.punch_time = b.punch_time AND a.id != b.min_id;
-- নির্দিষ্ট ৩ দিনের (৭ মার্চ, ৮ মার্চ এবং ১০ মার্চ ২০২৬) অ্যাটেনডেন্স ডাটা সর্বশেষ সময়ের ক্রমানুসারে (DESC) দেখতে
SELECT * FROM `attendances` WHERE DATE(`punch_time`) IN ('2026-03-07','2026-03-08','2026-03-10') ORDER BY `punch_time` DESC;
-- আজকের দিনে যেসব ডিভাইস থেকে অ্যাটেনডেন্স এসেছে, সেই ইউনিক device_id গুলোর লিস্ট ক্রমানুসারে দেখতে
SELECT DISTINCT device_id FROM attendances WHERE punch_time >= CURDATE() AND punch_time < CURDATE() + INTERVAL 1 DAY ORDER BY `attendances`.`device_id` ASC
-- যেসব user_id তে শুধু সংখ্যা (digits) নেই (যেমন: অক্ষর বা স্পেশাল ক্যারেক্টার আছে) সেগুলো বের করতে
SELECT user_id FROM attendances WHERE user_id NOT REGEXP '^[0-9]+$';
-- যেসব ডাটার স্ট্যাটাস 0 এবং পাঞ্চ টাইম ১ জানুয়ারি ২০২৬ বা তার আগে, সেগুলোর স্ট্যাটাস 1 করতে
UPDATE `attendances` SET `status` = '1'  WHERE   `status` = 0 AND `punch_time` <= '2026-01-01';
-- যেসব ডাটার স্ট্যাটাস 0 এবং পাঞ্চ টাইম ৩০ মে ২০২৬ বা তার আগে, সেগুলোর স্ট্যাটাস 2 করতে
UPDATE `attendances` SET `status` = '2'  WHERE `status` = 0 AND `punch_time` <= '2026-05-30';
-- ৩০ জানুয়ারি ২০২৬ বা তার পরের সব অ্যাটেনডেন্স ডাটার স্ট্যাটাস রিচেক/প্রসেস করার জন্য 0 করতে
UPDATE `attendances` SET `status` = '0'  WHERE `punch_time` >= '2026-01-30';
-- ইউজারের ID ১৫ থেকে পরিবর্তন করে ৩৮ এ আপডেট করতে
UPDATE `attendances` SET `user_id` = '38' WHERE `user_id` = '15';
-- নির্দিষ্ট কিছু ইউজার আইডি (১৭২৮৯১, ১৭২৮৯২)-র স্ট্যাটাস রি-প্রসেস করার জন্য 0 করতে
UPDATE `attendances` 
SET `status` = '0' 
WHERE `user_id` IN (
    '172891','172892',
);
-- ২৪ জুন ২০২৫ বা তার পরের সব লগ-এর স্ট্যাটাস 0 করতে
UPDATE `attendance_log` SET `status` = '0' WHERE `checktime` >= '2025-06-24 00:00:00';
-- ৩১ ডিসেম্বর ২০২৫ বা তার আগের সব লগ-এর স্ট্যাটাস প্রসেসড বা Processed (1) হিসেবে চিহ্নিত করতে
UPDATE `attendance_log` SET `status` = '1' WHERE `checktime` <= '2025-12-31 00:00:00';
-- ৩৮ নম্বর ইউজারের সব লগের স্ট্যাটাস 0 করতে
UPDATE `attendance_log` SET `status` = '0' WHERE `user_id` = 38;
-- অরিজিনাল লগে ইউজারের ID ১৫ থেকে ৩৮ এ পরিবর্তন করতে
UPDATE `attendance_log` SET `user_id` = '38' WHERE `user_id` = 15;
-- ৩১ আগস্ট ২০২৪ বা তার আগের সব লগের স্ট্যাটাস রি-সেট (0) করতে
UPDATE `attendance_log` SET `status` = '0' WHERE `checktime` <= '2024-08-31 00:00:00' ;
-- ভুল ইউজারের (38777) ডাটা সঠিক ইউজার (312)-এ ট্রান্সফার করতে
UPDATE attendance_log SET user_id= 312 WHERE user_id = 38777
-- নির্দিষ্ট ইউজার (312)-এর স্ট্যাটাস রি-প্রসেসের জন্য 0 করতে
UPDATE attendance_log SET status = 0 WHERE user_id= 312 ;
🗑️ ৫. অনাকাঙ্ক্ষিত ডাটা ডিলিট ও টেবিল কাস্টমাইজেশন
-- ৩১ ডিসেম্বর ২০২৫-এর পরের সব অ্যাটেনডেন্স ডাটা মুছে ফেলতে
DELETE FROM attendances WHERE punch_time >= '2025-12-31';

-- ২৭ নভেম্বর ২০২৫-এর পরের সব অ্যাটেনডেন্স লগ মুছে ফেলতে
DELETE FROM tbl_attendance_log WHERE attendance_date >= '2025-11-27';

-- যেসব user_id তে শুধু সংখ্যা নেই (অক্ষর বা আবর্জনা ডাটা রয়েছে) সেগুলো মুছে ফেলতে
DELETE FROM attendances WHERE user_id NOT REGEXP '^[0-9]+$';

-- user_id কলামের ডাটা টাইপ INT (পূর্ণসংখ্যা) এবং ডিফল্ট মান NULL হিসেবে পরিবর্তন করতে
ALTER TABLE `attendances` CHANGE `user_id` `user_id` INT NULL DEFAULT NULL;
-- Windows Run (Win + R) কাস্টম হিস্ট্রি ডিলিট করার নিয়ম:
Windows-এ Run (Windows + R) এর হিস্টরি (ইতিহাস) ডিলেট করার কয়েকটি উপায় আছে। নিচে সহজভাবে ব্যাখ্যা করছি:
🧹 পদ্ধতি ১: Registry Editor ব্যবহার করে

Windows + R চাপুন, তারপর লিখুন regedit → Enter চাপুন।

নিচের লোকেশনটিতে যান:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

ডান পাশে আপনি Run-এ টাইপ করা পুরনো কমান্ডগুলোর লিস্ট (a, b, c... নামে) দেখতে পাবেন।
যেগুলো আপনি মুছে ফেলতে চান, সেগুলোর ওপর রাইট ক্লিক করে Delete দিন।

MRUList নামক ভ্যালুটি ডিলিট করবেন না।
কাজ শেষ হলে Regedit বন্ধ করে দিন।
TRUNCATE Table a Quarry -- to delete all data in the tables
USE safedelivery_courierdb;

TRUNCATE TABLE delivery_branch_transfers;
TRUNCATE TABLE delivery_branch_transfer_details;

TRUNCATE TABLE parcels;
TRUNCATE TABLE parcel_logs;
TRUNCATE TABLE parcel_delivery_payments;
TRUNCATE TABLE parcel_delivery_payment_details;
TRUNCATE TABLE parcel_merchant_delivery_payments;
TRUNCATE TABLE parcel_merchant_delivery_payment_details;

TRUNCATE TABLE parcel_payment_requests;
TRUNCATE TABLE parcel_pickup_requests;

TRUNCATE TABLE return_branch_transfers;
TRUNCATE TABLE return_branch_transfer_details;

TRUNCATE TABLE rider_payments;
TRUNCATE TABLE rider_runs;
TRUNCATE TABLE rider_run_details;
-- to merchant_id, COUNT(*) AS occurrence_count
SELECT merchant_id, COUNT(*) AS occurrence_count
FROM merchant_service_area_return_charges
GROUP BY merchant_id
HAVING COUNT(*) > 3;
DELETE merchants, merchant_shops
DELETE merchants, merchant_shops
FROM merchants
LEFT JOIN merchant_shops ON merchants.id = merchant_shops.merchant_id
WHERE merchants.m_id = 'M-0304';
DELETE merchants, merchant_shops
DELETE m, ms
FROM merchants m
LEFT JOIN merchant_shops ms ON m.id = ms.merchant_id
WHERE m.m_id = 'M-0132';
DELETE merchants, merchant_shops
DELETE ms, m FROM merchants m JOIN merchant_shops ms ON m.id = ms.merchant_id WHERE m.m_id ='M-0243';
Parcel Return Charge Update
UPDATE `parcels` SET `return_charge` = '0' WHERE `return_charge` != 0 AND `delivery_type` IN (1,2);
Create Time Update
SET @time := NOW();

UPDATE merchants
SET created_at = (@time := DATE_ADD(@time, INTERVAL 1 SECOND))
ORDER BY id ASC;
Number 0 Add
UPDATE riders
SET contact_number = CONCAT('0', contact_number);
-- TO Insart merchant Shop
INSERT INTO merchant_shops (shop_name, shop_address, merchant_id, branch_id, district_id, area_id, contact_number, status, is_default, created_at, updated_at)
SELECT
    company_name, 
    address, 
    id AS merchant_id, 
    branch_id, 
    district_id, 
    area_id, 
    contact_number, 
    1 AS status, 
    1 AS is_default, 
    NOW() AS created_at, 
    NOW() AS updated_at
FROM merchants;
-- UPDATE parcels OTP Code
UPDATE parcels
SET parcel_code = FLOOR(1000 + RAND() * 8000)
WHERE status IN (14, 24);
-- Merchant Payment Check
SELECT * FROM parcel_merchant_delivery_payments WHERE total_payment_amount != 0 AND total_payment_received_amount = 0 AND status = 2
-- Merchant Payment Check
SELECT p.id
FROM parcels p
JOIN parcel_merchant_delivery_payment_details pd
    ON p.id = pd.parcel_id
WHERE p.merchant_id = 444
  AND p.payment_type != 5;
Parcel Return And Update
UPDATE rider_run_details
SET 
    complete_note = 'Out Of Coverage',
    collected_amount = 0,
    status = 7,
    delivery_type = 4
WHERE rider_run_id = 15071;
Parcel Return And Update
UPDATE `rider_run_details`
SET 
    `complete_note` = 'Out Of Coverage',
    `collected_amount` = 0,
    `status` = 7,
    `delivery_type` = 4
WHERE `rider_run_id` = 15071;
Parcel Status Update
UPDATE `parcels` SET 
 `status` = '24'
 WHERE `parcel_invoice` IN (

);
total charge Update
UPDATE parcels
SET cod_charge = 0, cod_percent = 0
WHERE merchant_id = 345 AND cod_percent = 1;
CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ALTER TABLE merchant_shops CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- This query will insert new records into the `merchant_shops` table by selecting data from the `merchants` table and transforming it as needed.
INSERT INTO merchant_shops (shop_name, shop_address, merchant_id, branch_id, district_id, area_id, contact_number, status, is_default, created_at, updated_at)
SELECT 
    company_name AS shop_name, 
    address AS shop_address, 
    id AS merchant_id, 
    branch_id, 
    district_id, 
    area_id, 
    contact_number, 
    1 AS status, 
    1 AS is_default,
    NOW() AS created_at,
    NOW() AS updated_at
FROM 
    merchants;
TRUNCATE TABLE
TRUNCATE TABLE easyfast_courierdb.delivery_branch_transfers;
TRUNCATE TABLE easyfast_courierdb.delivery_branch_transfer_details;

TRUNCATE TABLE easyfast_courierdb.parcels;
TRUNCATE TABLE easyfast_courierdb.parcel_logs;
TRUNCATE TABLE easyfast_courierdb.parcel_delivery_payments;
TRUNCATE TABLE easyfast_courierdb.parcel_delivery_payment_details;

TRUNCATE TABLE easyfast_courierdb.parcel_merchant_delivery_payments;
TRUNCATE TABLE easyfast_courierdb.parcel_merchant_delivery_payment_details;

TRUNCATE TABLE easyfast_courierdb.parcel_payment_requests;
TRUNCATE TABLE easyfast_courierdb.parcel_pickup_requests;


TRUNCATE TABLE easyfast_courierdb.pathao_orders;
TRUNCATE TABLE easyfast_courierdb.pathao_order_details;
TRUNCATE TABLE easyfast_courierdb.pathao_order_detail_logs;
TRUNCATE TABLE easyfast_courierdb.pathao_order_details;


TRUNCATE TABLE easyfast_courierdb.return_branch_transfers;
TRUNCATE TABLE easyfast_courierdb.return_branch_transfer_details;

TRUNCATE TABLE easyfast_courierdb.rider_payments;
TRUNCATE TABLE easyfast_courierdb.rider_runs;
TRUNCATE TABLE easyfast_courierdb.rider_run_details;






TRUNCATE TABLE easyfast_courierdb.branches;
TRUNCATE TABLE easyfast_courierdb.branch_users;

TRUNCATE TABLE easyfast_courierdb.branch_users;

TRUNCATE TABLE easyfast_courierdb.expenses;
TRUNCATE TABLE easyfast_courierdb.email_verifications;

TRUNCATE TABLE easyfast_courierdb.merchants;
TRUNCATE TABLE easyfast_courierdb.merchant_service_area_charges;
TRUNCATE TABLE easyfast_courierdb.merchant_service_area_cod_charges;
TRUNCATE TABLE easyfast_courierdb.merchant_service_area_return_charges;

TRUNCATE TABLE easyfast_courierdb.news_letters;
TRUNCATE TABLE easyfast_courierdb.notifications;

TRUNCATE TABLE easyfast_courierdb.riders;
TRUNCATE TABLE easyfast_courierdb.send_boxes;

TRUNCATE TABLE easyfast_courierdb.service_area_weight_package;
TRUNCATE TABLE easyfast_courierdb.staff;
TRUNCATE TABLE easyfast_courierdb.staff_payments;
TRUNCATE TABLE easyfast_courierdb.visitor_messages;
-- আপনার রিকোয়ারমেন্ট অনুযায়ী, parcels টেবিলে যে সকল merchant_id ব্যবহার করা হয়েছে, শুধু সেই মার্চেন্টদের ডেটা রেখে merchants টেবিল থেকে বাকি সব মার্চেন্টকে ডিলিট করার জন্য একটি SQL কুয়েরি লিখতে হবে।
DELETE FROM `merchants` WHERE `id` NOT IN ( SELECT DISTINCT `merchant_id` FROM `parcels` WHERE `merchant_id` IS NOT NULL );