Solved

Trouble shooting SQL

Posted on 2015-01-11
10
82 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
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…

910 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

22 Experts available now in Live!

Get 1:1 Help Now