473,472 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problems with query

M
I am trying to tie two tables of data together and I'm having some
issues.

table 1 has about 1700 rows
table 2 has about 1000 rows
table 3 has about 70

they all have one column in common, provider number.

select a.provider, a.[survey-date], a.tag, a.code, a.[scope-severity],
a.state, a.facilityname,
c.prov, c.defic_dt, c.tag_no, c.scopesev, c.theirnam, b.[name]
from table1 a
inner join table3 b on b.prov = a.provider
inner join table2 c on b.prov = c.prov

problem is, I am getting 35000 rows instead of 2700.

What am I missing?
thanks,
M@

Jul 12 '06 #1
1 1066
On 12 Jul 2006 13:42:50 -0700, M@ wrote:
>I am trying to tie two tables of data together and I'm having some
issues.

table 1 has about 1700 rows
table 2 has about 1000 rows
table 3 has about 70

they all have one column in common, provider number.

select a.provider, a.[survey-date], a.tag, a.code, a.[scope-severity],
a.state, a.facilityname,
c.prov, c.defic_dt, c.tag_no, c.scopesev, c.theirnam, b.[name]
from table1 a
inner join table3 b on b.prov = a.provider
inner join table2 c on b.prov = c.prov

problem is, I am getting 35000 rows instead of 2700.

What am I missing?
thanks,
M@
Hi M@,

Let's say that for a specific provider, there are 6 rows in table 1, 4
rows in table 2 and 5 rows in table 3. Since your join conditions only
specify that the "provider" values should be equal, each of the 6 rows
for this provider will be joined to each of the 5 in table 3, yielding
30 rows in the intermediate result - and each of those 30 will be
combined with each of the 4 rows for this provider in table 2. The end
result will have 4 * 30 = 120 rows for this single provider!

If you need help correcting the query, then you'll have to post more
details: the structure of your tables (as CREATE TABLE statements,
including all constraints, properties and indexes), some well-chosen
rows of sample data (posted as INSERT statements) and the exected
results.

--
Hugo Kornelis, SQL Server MVP
Jul 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: carverk | last post by:
Hello All I'm in the middle of moving a MS Access DB to a MySql backend. I have figured out about 90% of the problems I have faced, execpt for this one. I have 3 Queries, which pull records...
3
by: AndyBell | last post by:
Hi all! I have an Access 2000 database for the Habiat for Humanity where I work. This is the second database I have written and it gets a bit more complex each time... I have learned much and...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
2
by: John Ortt | last post by:
Hi All, I have a database in Access 97 which works fine but our company is converting from NT4 to XP Pro and in the process changing Office 97 for Office 2003. I have tried to convert the 97...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
2
by: goodnamesalltaken | last post by:
Hello fellow python users, I've been working on a basic implementation of a privilege separated web server, and I've goto the point of running a basic cgi script. Basically when the execCGI...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
4
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have...
2
by: webhead74 | last post by:
Hi, I'm having intermittent problems with queries from my php script to a postgresql database. I have a form where I can enter a search query - for instance a last name. This leads to a...
2
by: thewilldog | last post by:
Hello, I've reviewed the archives here to address the issue, but I'm still running into problems. I've got a table field populated with the record date in text "YYYYMMDD" To convert it into a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.