Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: MS SQL query with many tables


Message #1 by "Craig Worcester" <craig.worcester@g...> on Thu, 1 Aug 2002 13:42:28
This all looks very confusing to me, but my brain is so foggy now that I 
can?t see the wood for the trees.

I've put an MS SQL database together using relational tables.
We have several tables:

table 1: users
fields: user_id, first_name, last_name

table2: curricula
fields: curricula_id, curricula_name

table3: content
fields: content_id, content_name

table4: curricula_user
fields: user_id, curricula_id

table5: curricula_content
fields: course_id, curric_id

table6: verify_dates
fields: course_id, user_id, supporter_verify_date

I've used Microsoft Query to general an initial SQL statement, and would 
like to use a JOIN once I can get the statement working. The sample I 
have is:

SELECT content.content_name, content.pass_percent, content.format, 
content.doc_name, verify_dates.supporter_verify_date
FROM glasstap.dbo.content content, glasstap.dbo.curricula_content 
curricula_content, glasstap.dbo.curricula_users curricula_users, 
glasstap.dbo.verify_dates verify_dates
WHERE content.content_id = curricula_content.content_id AND 
curricula_content.curricula_id = curricula_users.curricula_id AND 
curricula_content.content_id = verify_dates.content_id AND 
curricula_users.user_id = verify_dates.user_id AND 
((curricula_content.curricula_id=23) AND (curricula_users.user_id=1))

The problem I have is that curricula_content is attached to 3 records 
from the 'content' table, but because I need to show 
the 'supporter_verify_date' record, and say only 2 matching records 
exist  in this table, I can only get it to show 2 records, when in fact 
it should show 3. With the third not showing a date.

Hope someone can help me. :-)

Thanks
Craig
Message #2 by "Manuel Sandoval" <mhuezo@f...> on Sat, 17 Aug 2002 02:29:43
I have the same problem and no body know the answer
----------------------------------------------------

> This all looks very confusing to me, but my brain is so foggy now that 
I 
c> an?t see the wood for the trees.

> I've put an MS SQL database together using relational tables.
W> e have several tables:

> table 1: users
f> ields: user_id, first_name, last_name

> table2: curricula
f> ields: curricula_id, curricula_name

> table3: content
f> ields: content_id, content_name

> table4: curricula_user
f> ields: user_id, curricula_id

> table5: curricula_content
f> ields: course_id, curric_id

> table6: verify_dates
f> ields: course_id, user_id, supporter_verify_date

> I've used Microsoft Query to general an initial SQL statement, and 
would 
l> ike to use a JOIN once I can get the statement working. The sample I 
h> ave is:

> SELECT content.content_name, content.pass_percent, content.format, 
c> ontent.doc_name, verify_dates.supporter_verify_date
F> ROM glasstap.dbo.content content, glasstap.dbo.curricula_content 
c> urricula_content, glasstap.dbo.curricula_users curricula_users, 
g> lasstap.dbo.verify_dates verify_dates
W> HERE content.content_id = curricula_content.content_id AND 
c> urricula_content.curricula_id = curricula_users.curricula_id AND 
c> urricula_content.content_id = verify_dates.content_id AND 
c> urricula_users.user_id = verify_dates.user_id AND 
(> (curricula_content.curricula_id=23) AND (curricula_users.user_id=1))

> The problem I have is that curricula_content is attached to 3 records 
f> rom the 'content' table, but because I need to show 
t> he 'supporter_verify_date' record, and say only 2 matching records 
e> xist  in this table, I can only get it to show 2 records, when in fact 
i> t should show 3. With the third not showing a date.

> Hope someone can help me. :-)

> Thanks
C> raig
Message #3 by "Manuel Sandoval" <mhuezo@f...> on Sat, 17 Aug 2002 02:40:26
I have the Same problem, and not body have the answer to help US
-----------------------------------------------------------------------
> This all looks very confusing to me, but my brain is so foggy now that 
I 
c> an?t see the wood for the trees.

> I've put an MS SQL database together using relational tables.
W> e have several tables:

> table 1: users
f> ields: user_id, first_name, last_name

> table2: curricula
f> ields: curricula_id, curricula_name

> table3: content
f> ields: content_id, content_name

> table4: curricula_user
f> ields: user_id, curricula_id

> table5: curricula_content
f> ields: course_id, curric_id

> table6: verify_dates
f> ields: course_id, user_id, supporter_verify_date

> I've used Microsoft Query to general an initial SQL statement, and 
would 
l> ike to use a JOIN once I can get the statement working. The sample I 
h> ave is:

> SELECT content.content_name, content.pass_percent, content.format, 
c> ontent.doc_name, verify_dates.supporter_verify_date
F> ROM glasstap.dbo.content content, glasstap.dbo.curricula_content 
c> urricula_content, glasstap.dbo.curricula_users curricula_users, 
g> lasstap.dbo.verify_dates verify_dates
W> HERE content.content_id = curricula_content.content_id AND 
c> urricula_content.curricula_id = curricula_users.curricula_id AND 
c> urricula_content.content_id = verify_dates.content_id AND 
c> urricula_users.user_id = verify_dates.user_id AND 
(> (curricula_content.curricula_id=23) AND (curricula_users.user_id=1))

> The problem I have is that curricula_content is attached to 3 records 
f> rom the 'content' table, but because I need to show 
t> he 'supporter_verify_date' record, and say only 2 matching records 
e> xist  in this table, I can only get it to show 2 records, when in fact 
i> t should show 3. With the third not showing a date.

> Hope someone can help me. :-)

> Thanks
C> raig

  Return to Index