0

I have this SQL query that I use as part of a Visual C++ application that works with a Microsoft Access Database:

strQuery = _T("SELECT [Public Talk Titles].*, ")
           _T("[Public Talk Categories].Description AS [Category Description] ")
           _T("FROM [Public Talk Categories] ")
           _T("INNER JOIN [Public Talk Titles] ")
           _T("ON [Public Talk Categories].Category = [Public Talk Titles].Category ")
           _T("ORDER BY [Public Talk Titles].[Talk Number]");

pTalkRecordset->Open(CRecordset::snapshot,(LPCTSTR)strQuery, CRecordset::readOnly);

In the Public Talk Categories I have the following values:

Bible / Dieu    BD
Derniers jours / Jugement de Dieu   DJ
Epreuves / Difficultés  ED
Evangélisation / Ministère  EM
Famille / Jeunes    FJ
Foi / Spiritualité  FS
Monde, pas partie du    МР
Non Spécifié    NS
Normes / Qualités chrétiennes   NQ
Religion / Culte    RC
Royame / Paradis    RP

In my resulting record set, it has excluded all records that have a category of MP. Why is this?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

1 Answers1

0

Presumably because there are no matching records in [Public Talk Titles].

If you want all the categories, use a left join instead of a right join.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • There are records in the Public Talk Titles table. – Andrew Truckle Oct 02 '16 at 17:31
  • @AndrewTruckle But does it have the category "MP" ? An inner join only returns records when the linked value of the joined field is in both tables. [more info](http://stackoverflow.com/questions/38549/what-is-the-difference-between-inner-join-and-outer-join) – LukStorms Oct 02 '16 at 17:52
  • It does, at least it looks like it does visually. What I did (not ideal) was to upgrade to a Unicode database, next I changed all the MP codes to XX and renamed it to XX in the categories table too. Now all records display using the above query. At least it works now. I just don't know why it wouldn't before since it had about 20 records in the titles table with a code of MP. But it didn't find them. At least it works now. – Andrew Truckle Oct 02 '16 at 19:19