Thema: Delphi SQL-Problem mal wieder

Einzelnen Beitrag anzeigen

Grolle

Registriert seit: 5. Nov 2004
Ort: Coesfeld
1.268 Beiträge
 
Delphi 2010 Professional
 
#7

Re: SQL-Problem mal wieder

  Alt 18. Mai 2009, 21:15
SQL-Code:
Tree
(ID, NAME, PARENT)
(6, 'Kunden', 0);
(8, 'Behörden', 0);
(9, 'Banken', 0);
(10, 'Intern', 6);

Tree2Contact
(ID, TREE_ID, CONTACT_ID)
(1, 8, 22);
(2, 6, 25);
(3, 6, 22);
SQL-Code:
SELECT distinct(tree.name) as name, tree.id as id, tree2contact.contact_id as contact_id from tree left join tree2contact on tree.id=tree2contact.tree_id
Where ((tree2contact.contact_id=25) or (tree2contact.contact_id is Null)) and tree.parent=0 order by tree.name
soll:
('Banken', 9, NULL);
('Behörden', 8, NULL);
('Kunden', 6, 25);
ist:
('Banken', 9, NULL);
('Kunden', 6, 25);


bei:
SQL-Code:
SELECT distinct(tree.name) as name, tree.id as id, tree2contact.contact_id as contact_id from tree left join tree2contact on tree.id=tree2contact.tree_id
Where ((tree2contact.contact_id=22) or (tree2contact.contact_id is Null)) and tree.parent=0 order by tree.name
soll:
('Banken', 9, NULL);
('Behörden', 8, 22);
('Kunden', 6, 22);
und ist auch so. (Teste mit IBExpert)

viele Grüße ...

  Mit Zitat antworten Zitat