February 5, 2010 at 6:45 am
Hi
This query does not work in my SQL 2008 Server:
SELECT dbo.ip2Tags.ip, dbo.ip2Tags.MediaId
FROM dbo.ip2Tags LEFT OUTER JOIN
dbo.ip2location ON dbo.ip2Tags.ip BETWEEN dbo.ip2location.ipmin AND dbo.ip2location.ipmax
WHERE (dbo.ip2Tags.MediaId = 'mz-1840')
What is wrong in your opinion.
Thank you for your help
February 5, 2010 at 6:58 am
Not enough info to help you significantly.
What error are you getting?
What are the expected results?
What are the current results?
What is the table definition?
What data do you have in thsoe tables?
The last 2 questions are best answered by posting scripts that will create the tables, keys, indexes and enough sample data to answer the question.
February 5, 2010 at 7:08 am
Are you getting some kind of error?
February 5, 2010 at 7:15 am
djbuzz (2/5/2010)
HiThis query does not work in my SQL 2008 Server:
SELECT dbo.ip2Tags.ip, dbo.ip2Tags.MediaId
FROM dbo.ip2Tags LEFT OUTER JOIN
dbo.ip2location ON dbo.ip2Tags.ip BETWEEN dbo.ip2location.ipmin AND dbo.ip2location.ipmax
WHERE (dbo.ip2Tags.MediaId = 'mz-1840')
What is wrong in your opinion.
Thank you for your help
What's the point of the LEFT JOINed table?
You may as well run this:
SELECT t.ip, t.MediaId
FROM dbo.ip2Tags t
WHERE t.MediaId = 'mz-1840'
You will get the same result, probably faster.
If you are trying to use the location table as a filter, then you probably need to inner join it to the tags table. Having done this, if your results are unexpected, then you should review the join condition.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 5, 2010 at 7:22 am
I reformatted your code, made a few changes (you really need to look at removing 3 part naming as , iirc, this is being depreciated in future versions of SQL Server so I encourage using table aliases in your from clauses).
I don't see anything syntactically wrong with the code:
SELECT
i2t.ip,
i2t.MediaId
FROM
dbo.ip2Tags i2t
LEFT OUTER JOIN dbo.ip2location i2l
ON i2t.ip BETWEEN i2l.ipmin AND i2l.ipmax
WHERE
(i2t.MediaId = 'mz-1840')
February 5, 2010 at 7:29 am
lyn - as chris morris says - looks like he doesn't need the left outer join
MVDBA
February 5, 2010 at 7:32 am
Good catch... but it's only true if we're seeing the whole picture... it's rare that we have the real query here. Quite often we are missing columns in the select and where predicates or even order bys.
Let's see what he has to say about that.
February 5, 2010 at 8:05 am
Ninja's_RGR'us (2/5/2010)
Good catch... but it's only true if we're seeing the whole picture... it's rare that we have the real query here. Quite often we are missing columns in the select and where predicates or even order bys.Let's see what he has to say about that.
I have to agree here, how many times have we found that the OP has only given us a small part of the big picture.
February 5, 2010 at 9:09 am
no no real query.
I think the problem is coming from the ip columns that are varchar.
I tried to query with cast or convert but the broblem remains: "timeout"
I'll try to use bigint columns instead of varchar.
Thx
February 5, 2010 at 9:35 am
Please post the entire and complete error message.
February 5, 2010 at 10:18 am
How about a simple lock?
How about not enough ram to process all the data?
I can keep on guessing but we need more info!!!
Xml Execution plan would be nice.
February 5, 2010 at 10:26 am
Ninja's_RGR'us (2/5/2010)
How about a simple lock?How about not enough ram to process all the data?
I can keep on guessing but we need more info!!!
Xml Execution plan would be nice.
No, SQL Server 2008, provide the Graphical execution plan (saved as a .sqlplan file, zipped, then uploaded).
February 5, 2010 at 11:31 am
Lynn Pettis (2/5/2010)
Ninja's_RGR'us (2/5/2010)
How about a simple lock?How about not enough ram to process all the data?
I can keep on guessing but we need more info!!!
Xml Execution plan would be nice.
No, SQL Server 2008, provide the Graphical execution plan (saved as a .sqlplan file, zipped, then uploaded).
Cool :hehe:
February 5, 2010 at 12:53 pm
Anybody wanna beer? It's friday! My shout. Get yer shoes on. Lynn I'll get you a coke.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
February 5, 2010 at 1:02 pm
lobbymuncher (2/5/2010)
Anybody wanna beer? It's friday! My shout. Get yer shoes on. Lynn I'll get you a coke.
Actually, I'll take a fresh brewed sweet tea, just not as sweet as they make it in Atlanta. I prefer sugar in my tea, not tea in my sugar. ๐
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply