Print Page | Close Window

Union and Joins

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12497
Printed Date: 30 March 2026 at 7:16am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Union and Joins
Posted By: zaboss
Subject: Union and Joins
Date Posted: 11 November 2004 at 8:44am
I have 3 tables:
Tabel 1- tblLogin (only relevant fields)
UserName,  BUM (Business Unit Manager), ASM (Area Sales Manager)
Tabel 2 - tblWork1
strSeenBy, strData
Tabel 3 - tblWork2
strSeenBy, strData
Tabel 4 -tblWork3
strSeenBy, strData
strSeenBy = UserName

Table 1 is holding the informations about all users. Table 2-4 holds information about users work. In one day, a user might have records in 1, 2 or all 3 tblWork. What I need is to print a report on how many working days (strData) has each users.
In order to find out how many working days has a single user, I use UNION SELECT DISTINCT strData with all table from 2-4. I don't know how to make is loop through table1 to count this for all the user belonging to an BUM(ASM).
To distinct between ASM and BUM I have a an If-then:
If UserISBUM then
sql for BUM
Else
sql for ASM
End if.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: dj air
Date Posted: 15 November 2004 at 5:36am

SQL = "SELECT Count(tablename.fieldname) AS BUM FROM tablename where Field = UserISBUM"

BUM = Connection("BUM")

BUM = number

hope that answers your question the above code counts the number of records with x spec.

just reading do you mean you can get it to make the report with just the first record

you want to use

do while NOT connection.eof

code

connectoion.movenext

loop

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net