Solved

Trouble shooting SQL

Posted on 2015-01-11
10
80 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
  • 4
  • 3
  • 3
10 Comments
 
LVL 33

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
 
LVL 33

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 33

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now