cescentman
asked on
Trouble shooting SQL
I am experiencing a problem I have no idea how to troubleshoot. The SQL I'm using is:-
This only returns results for k.idKeyword = 146
However using:-
... returns results. As does
... or:-
In fact as far as I can tell any other combination of:-
... works as expected. I'm at a complete loss as to what to look for to troubleshoot this. I would appreciate help on this.
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
This only returns results for k.idKeyword = 146
However using:-
WHERE k.idKeyword = 151
... returns results. As does
WHERE k.idKeyword = 151 OR k.idKeyword = 147
... or:-
WHERE k.idKeyword = 150 OR k.idKeyword = 146
In fact as far as I can tell any other combination of:-
k.idKeyword = ?? OR k.idKeyword = ??
... works as expected. I'm at a complete loss as to what to look for to troubleshoot this. I would appreciate help on this.
ASKER
Yes sorry If I wasn't explicit enough.
As I say:-
... returns results
As I say:-
WHERE k.idKeyword = 151
... returns results
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
Wilder1626,
Do you mean like:
WHERE k.idKeyword in (151, 146)
Do you mean like:
WHERE k.idKeyword in (151, 146)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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.
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.
ASKER
Oops wrong boxes
I'm glad i was able to help
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?