SELECT id, "name", logo, email, created_by, updated_by, updated_at, created_at, tell_number, cell_number, contact_person, address
FROM public.customer;

select distinct brand from sjreport 

CREATE TABLE IF NOT EXISTS brand (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    image_path VARCHAR(255)
);

INSERT INTO brand (name) VALUES 
('BEL'),
('BISTO'),
('BUFFALO'),
('BULL BRAND'),
('CASTELLO'),
('CRYSTAL VALLEY'),
('HAZELDENE'),
('HINDS'),
('HOUSEBRAND'),
('KIRI'),
('LANCEWOOD'),
('LURPAK'),
('OMG'),
('PAKCO'),
('PNP'),
('POT O GOLD'),
('PURE REFRESH'),
('RHODES'),
('RITEBRAND'),
('SIMPLE TRUTH'),
('SUNFIRST'),
('THE LAUGHING COW'),
('TROTTERS'),
('ZING');

select * from brand

CREATE TABLE IF NOT EXISTS customer_brand (
    customer_id INT NOT NULL,
    brand_id INT NOT NULL,
    PRIMARY KEY (customer_id, brand_id),
    FOREIGN KEY (customer_id) REFERENCES customer(id) ON DELETE CASCADE,
    FOREIGN KEY (brand_id) REFERENCES brand(id) ON DELETE CASCADE
);


'BEL'
'CASTELLO'
'KIRI'
'LANCEWOOD'
'LURPAK'
'PNP'
'THE LAUGHING COW'
'CRYSTAL VALLEY'
'SIMPLE TRUTH'


INSERT INTO customer_brand (customer_id, brand_id)
VALUES 
(67, 1),  -- BEL
(67, 5),  -- CASTELLO
(67, 10), -- KIRI
(67, 11), -- LANCEWOOD
(67, 12), -- LURPAK
(67, 15), -- PNP
(67, 22), -- THE LAUGHING COW
(67, 6),  -- CRYSTAL VALLEY
(67, 20); -- SIMPLE TRUTH


INSERT INTO customer_brand (customer_id, brand_id)
VALUES 
(1, 2),   -- BISTO
(1, 3),   -- BUFFALO
(1, 4),   -- BULL BRAND
(1, 7),   -- HAZELDENE
(1, 8),   -- HINDS
(1, 9),   -- HOUSEBRAND
(1, 13),  -- OMG
(1, 14),  -- PAKCO
(1, 16),  -- POT O GOLD
(1, 17),  -- PURE REFRESH
(1, 18),  -- RHODES
(1, 19),  -- RITEBRAND
(1, 21),  -- SUNFIRST
(1, 23),  -- TROTTERS
(1, 24);  -- ZING


UPDATE product
SET customer_id = cb.customer_id
FROM brand b
JOIN customer_brand cb ON b.id = cb.brand_id
WHERE UPPER(b.name) = UPPER(product.brand);