Link to home
Start Free TrialLog in
Avatar of cescentman
cescentmanFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Trouble shooting SQL

I am experiencing a problem I have no idea how to troubleshoot. The SQL I'm using is:-

SELECT tk.idKeyword, k.keyword, t.name, p.name as path, v.netname, t.thumbnail, t.idThumb
FROM ((((ThumbnailKeyword tk
 INNER JOIN Keyword k ON tk.idKeyword = k.idKeyword) INNER JOIN Thumbnail t ON tk.idThumb = t.idThumb)
  INNER JOIN Path p ON t.idpath = p.idpath)
   INNER JOIN Volume v ON p.idvol = v.idVol)
WHERE k.idKeyword = 151 OR k.idKeyword = 146
ORDER BY t.idPath, t.name

Open in new window


This only returns results for k.idKeyword = 146

However using:-

WHERE k.idKeyword = 151

Open in new window


... returns results. As does

WHERE k.idKeyword = 151 OR k.idKeyword = 147

Open in new window


... or:-

WHERE k.idKeyword = 150 OR k.idKeyword = 146

Open in new window


In fact as far as I can tell any other combination of:-

k.idKeyword = ?? OR k.idKeyword = ??

Open in new window


... works as expected. I'm at a complete loss as to what to look for to troubleshoot this. I would appreciate help on this.
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

What is the problem. You have said what works. But you have not told what doesn't.

Do you mean:

WHERE k.idKeyword = 151 OR k.idKeyword = 146

returns records for 146 only where as you are expecting some records for 151 as well?
Avatar of cescentman

ASKER

Yes sorry If I wasn't explicit enough.

As I say:-

WHERE k.idKeyword = 151

Open in new window


... returns results
Avatar of Wilder1626
Is this working?

SELECT tk.idKeyword, k.keyword, t.name, p.name as path, v.netname, t.thumbnail, t.idThumb
FROM ((((ThumbnailKeyword tk
 INNER JOIN Keyword k ON tk.idKeyword = k.idKeyword) INNER JOIN Thumbnail t ON tk.idThumb = t.idThumb)
  INNER JOIN Path p ON t.idpath = p.idpath)
   INNER JOIN Volume v ON p.idvol = v.idVol)
WHERE k.idKeyword in ('151', '146')
ORDER BY t.idPath, t.name

Open in new window

Wilder1626,

Do you mean like:

WHERE k.idKeyword in (151, 146)
SOLUTION
Avatar of Wilder1626
Wilder1626
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think there must have been a problem with the original DB. I went back to the parent app that creates the DB and refreshed the data and now all is OK. Many thanks for your help on this.
I've requested that this question be closed as follows:

Accepted answer: 0 points for cescentman's comment #a40543856
Assisted answer: 250 points for Wilder1626's comment #a40543351
Assisted answer: 250 points for eghtebas's comment #a40543372

for the following reason:

Although the matter was resolved by me I thin the points ought to be allocated.
Oops wrong boxes
I'm glad i was able to help