MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 31st, 2003, 07:48 AM
truspam truspam is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 2 truspam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Comparing two tables for certain similarities

I have two tables. The first is Data, containing row upon row of values. The second is Param, which has a limited amount of rows, but contains only the specific values for 3 items that I am trying to select from the Data table.

I have created an Inner Join command that selects only the items from Data where Data.1=Param.1 and Data.2=Param.2 and Data.3=Param.3

But, after looking at the results, I am not sure that it actually succeeded in doing what I wanted it two. Is there another way to run this same type of query in order to give me something to compare results with?

Thanks

Reply With Quote
  #2  
Old December 31st, 2003, 08:38 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
no, there isn't

if you could give some sample rows from each table, sample output from your query, the sql used by your query, and an explanation of whatever it is you feel may be lacking from your approach, then we would have more to go on


Reply With Quote
  #3  
Old December 31st, 2003, 08:57 AM
truspam truspam is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 2 truspam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok, here goes

These are the fields in the Data table:
SENSOR_ID, TERM_NPA, TERM_NXX, ORIG_OCN, BILLING_ID, CALL_TYPE, AMA_CALL, STRU_CODE, CIC_CODE, MOU, CAR_MOU

These are the fields of the Param table:
SENSOR_ID, AMA_CALL, STRU_CODE

So, I am trying to find those rows in the Data table where the SENSOR_ID, AMA_CALL, STRU_CODE matches any of the rows from the Param table. If the row matches two of the three, I don't want it, I only want rows from the Data table that exactly match a row from the Param table.

So, in the data I may have something that has
SENSOR_ID of 19999, AMA_CALL of 160, STRU_CODE of 60

if there is no row in the Param table that has that sequence, I do not want to select it.

The problem is, that when runing a join query on this data, it only gives me 89 records out of 45,000 that match. From other data I have, I should have gotten way more matches.

My query looked like this:

SELECT * FROM Data
INNER JOIN Param ON
(Data.Sensor_ID=Param.Sensor_ID AND Data.AMA_Call=Param.Ama_Call AND Data.Stru_Code=Param.Stru_Code);

Reply With Quote
  #4  
Old December 31st, 2003, 09:06 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
your query looks fine

please show this "other data" that you have

i.e. please show some sample rows, so we can actually set up a test table ourselves, to test your query to see why it's not working


rudy

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Comparing two tables for certain similarities


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway