Solved

Missing Join Predicate

Posted on 2011-09-28
4
856 Views
Last Modified: 2012-05-12
I get a missing join predicate warning when I run a simplet single join query with a where clause on the join field.  Both tables fields are indexed.  Is this a false alarm or is there really something that can be done to fix this.  Here is a basic example:

select field1 from table1 t1 inner join table2 t2 on t1.field2 = t2.field2 where t1.field2 = 'myvalue'

It appears to be related to field2 being the join field and the criteria.
0
Comment
Question by:ws11
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36717422
The query looks OK to me, other than I would specify, in the select clause, either t1.field1 or t2.field1 (depending on which table you are drawing from).

There is absolutely nothing wrong with using the same column in the FROM clause and in the WHERE clause.
0
 

Author Comment

by:ws11
ID: 36717529
I was surprised that this was an issue.  I thought this might indicate that the indexing is a problem.  One thing that is different is that in one table the width is greater for field1 than the other table.  varchar(50) to varchar(40).

They are large tables though and I don't want any random side effects.
0
 
LVL 41

Accepted Solution

by:
ralmada earned 250 total points
ID: 36717550
>>Is this a false alarm or is there really something that can be done to fix this.<<

I would say it's a false alarm, most likely a bug in the optimizer. Having said that can also try:

select t1.field1 from table1 t1 inner join table2 t2 on t1.field2 = t2.field2 and t1.field2 = 'myvalue'


Also check this link discussing the warning message on SQL 2008:
http://www.scarydba.com/2009/09/15/no-join-predicate/
0
 

Author Comment

by:ws11
ID: 36718008
Yes that took care of it by putting the criteria in the join with the exception to one and I am trying to determine why it is different.  If I use two fields to join it is fine but a single can be more frustrating in this case.  This may be due to the other indexes on one of the join tables.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

9 Experts available now in Live!

Get 1:1 Help Now