Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trouble shooting SQL

Posted on 2015-01-11
10
Medium Priority
?
101 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1000 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

618 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