Siapkan dua tabel seperti gambar di atas Di delphi tambahkan button dan treeview isi button delphi dengan : procedure TF_penjualan_order.Button1Click(Sender: TObject); var CurrentDeptID, RecordDeptID: Integer; RootNode, DeptNode: TTreeNode; begin CurrentDeptID := 0; TreeView1.Items.Clear; RootNode := TreeView1.Items.Add(nil, 'Nama Barang'); DeptNode := nil; ZQuery1.SQL.Text := 'SELECT a.id_kategori, a.kategori, b.nama FROM kategori a INNER JOIN barang b ON (a.id_kategori=b.id_kategori) ORDER BY b.id_kategori, a.id_kategori'; ZQuery1.Open; try ZQuery1.First; while not ZQuery1.Eof do begin RecordDeptID := ZQuery1.FieldByName('id_kategori').AsInteger; if (DeptNode = nil) or (RecordDeptID <> CurrentDeptID) then begin DeptNode := TreeView1.Items.AddChild(RootNode, ZQuery1.FieldByName('kategori').AsString); CurrentDeptID := RecordDeptID