Solved

Trouble shooting SQL

Posted on 2015-01-11
10
93 Views
Last Modified: 2015-01-12
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.
0
Comment
Question by:cescentman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40543337
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?
0
 
LVL 1

Author Comment

by:cescentman
ID: 40543345
Yes sorry If I wasn't explicit enough.

As I say:-

WHERE k.idKeyword = 151

Open in new window


... returns results
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40543346
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

0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40543349
Wilder1626,

Do you mean like:

WHERE k.idKeyword in (151, 146)
0
 
LVL 11

Assisted Solution

by:Wilder1626
Wilder1626 earned 250 total points
ID: 40543351
sorry, yes

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

0
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 250 total points
ID: 40543372
cescentman,

I wonder if you could upload your DB to trouble shoot it. Your code seems okay. If I had access to t, I will check on the data type and quality in joining fields and criteria fields.
0
 
LVL 1

Author Comment

by:cescentman
ID: 40543856
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.
0
 
LVL 1

Author Comment

by:cescentman
ID: 40543863
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.
0
 
LVL 1

Author Closing Comment

by:cescentman
ID: 40543864
Oops wrong boxes
0
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40544114
I'm glad i was able to help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question