IElite
IElite

Reputation: 1848

Help with Delphi 7, ADO, & MS Access SQL Statement

I have three tables (in a MS Access Database 2000 file *.mdb)

Knowledge
id
question
answer

Knowledge_Keywords
id
knowledgeid
keywordsid

Keywords
id
keyword

Need to get all the keywords for a knowledge

Select distinct keyword from keywords KW
Join knowledge_keywords KKW on KKW.keywordid = KW.id
Join Knowledge K on K.id = KKW.knowledgeid
Where k.id = 10

of course 10 is a example, i actually use a parameter there

Where k.id = :AKnowId';

and fill it in in code

qry.Parameters.ParamByName('AKnowId').Value:= AKnowledgeId;

anyway, i think the SQL is qrong, any help would be greatly appreciated

Upvotes: 0

Views: 1257

Answers (2)

IElite
IElite

Reputation: 1848

Solved it!

Select distinct keyword
from (keywords KW
inner Join knowledge_keywords KKW on KKW.keywordid = KW.id)
inner Join Knowledge K on K.id = KKW.knowledgeid
Where k.id = 10

Upvotes: 1

Chris Thornton
Chris Thornton

Reputation: 15817

Get the SQL working properly within Access itself (make a query, try your SQL, see if it returns anything). THEN worry about Delphi.

Upvotes: 1

Related Questions