| Welcome Guest ( Log In | Register ) | Resend Validation Email |
|
![]() ![]() ![]() |
| santanu |
Posted: February 14, 2010 08:50 pm
|
||
|
Administrator Group: Admin Posts: 7,324 Member No.: 1 Joined: November 22, 2005 IGNOU:MCA Joining Year: 2006Study Centre:St. Xavier's College, Kolkata (2802) |
In these cases (and also in general, in order to save server space), upload files to 4shared using the specified button below the post and then paste the 4shared link in the post. |
||
| IMSF |
|
|
Tech for GenY Group: Bot IGNOU:MCA Joining Year:Study Centre: |
|
|
|
| Fakharuddin |
Posted: February 14, 2010 08:19 pm
|
||
|
Admitted Group: ACTIVE Members Posts: 58 Member No.: 6,574 Joined: June 11, 2008 IGNOU:MCA Joining Year: 2008Study Centre:Gauhati University Centre |
Hi Friends! I have solved this problem using VB. The codes are as below. Please check it and do comment.
|
||
| Fakharuddin | |
|
Admitted Group: ACTIVE Members Posts: 58 Member No.: 6,574 Joined: June 11, 2008 IGNOU:MCA Joining Year: 2008Study Centre:Gauhati University Centre |
You are right Santanu. I tried Chakrapani's code but it does not work. It produces an error - 'An updateable query is required'. So only VB code can help us.
|
| santanu |
Posted: February 09, 2010 10:12 pm
|
|
Administrator Group: Admin Posts: 7,324 Member No.: 1 Joined: November 22, 2005 IGNOU:MCA Joining Year: 2006Study Centre:St. Xavier's College, Kolkata (2802) |
In MS Access, I think you have to write VBScript code for looping through records.
|
| chakkrapani |
Posted: February 09, 2010 07:30 pm
|
|
M.Tech Group: Moderator Posts: 813 Member No.: 2,569 Joined: May 09, 2007 IGNOU:MCA Joining Year: 2007Study Centre:CHENNAI |
@Fakharuddin
The following query updates your requirement as shown in the output (I practically did it with ORACLE) UPDATE TBLCOUNTMEMBER A SET A.TOTALCOUNT = (SELECT COUNT(B.MID) FROM TBLMEMBER B WHERE A.MID = B.SPONSORID GROUP BY B.SPONSORID) / 10 rows updated. SQL> SELECT * FROM TBLCOUNTMEMBER; Hit return to continue.... MID SPONSORID TOTALCOUNT ---------- ---------- ---------- 0 -1 1 1 0 3 2 1 2 3 1 1 4 1 2 5 2 6 2 7 3 8 4 9 4 10 rows selected. |
| Sindhu Srikant |
Posted: February 09, 2010 01:14 pm
|
|
3rd Sem Group: ACTIVE Members Posts: 167 Member No.: 16,393 Joined: January 01, 2010 IGNOU:MCA Joining Year: 2008Study Centre: |
The query written by santanu does the same thing provided you loop it for each mid's. This looping can be done with the help of any programming language. But as far as i know MS Access does not support such complex queries(Pl/sql) to be written directly and executed(@others, am i right? ).
In Oracle we can write Cursors to handle such requirements. You'll learn more about Cursors in your fourth sem. |
| Fakharuddin |
Posted: February 09, 2010 01:38 am
|
|||||||||||||||||||||||||||||||||
|
Admitted Group: ACTIVE Members Posts: 58 Member No.: 6,574 Joined: June 11, 2008 IGNOU:MCA Joining Year: 2008Study Centre:Gauhati University Centre |
The query should update the totalCount field of tblCountMember as
mid 1 and sponsorid 1 is the same person. A member becomes a sponsor when he joins member under him. Member 1 is sponsor of member 2, 3 and 4. So memberCount is 3 for mid 1. |
|||||||||||||||||||||||||||||||||
| Sindhu Srikant |
Posted: February 08, 2010 01:26 pm
|
||||||
|
3rd Sem Group: ACTIVE Members Posts: 167 Member No.: 16,393 Joined: January 01, 2010 IGNOU:MCA Joining Year: 2008Study Centre: |
A small change, instead of tblCountMember, tblMember can be used to take the count, if the second table is to be built dynamically containing a subset of mid's.
|
||||||
| santanu |
Posted: February 05, 2010 10:19 pm
|
||
|
Administrator Group: Admin Posts: 7,324 Member No.: 1 Joined: November 22, 2005 IGNOU:MCA Joining Year: 2006Study Centre:St. Xavier's College, Kolkata (2802) |
I have doubts that the design of the table is correct. First of all, 1-to-1 relations does not have much meaning. These tables could be merged. Are sponsorid entries the same as mid...I mean is mid being used as sponsorid too? If so, it could be like this
Now, this will fill up the totalCount against only mid='1' and sponsorid='1'. This query has to be looped for all records, taking mid from 0..9 |
||
| Fakharuddin |
Posted: February 05, 2010 05:58 pm
|
|||||||||||||||||||||||||||||||||
|
Admitted Group: ACTIVE Members Posts: 58 Member No.: 6,574 Joined: June 11, 2008 IGNOU:MCA Joining Year: 2008Study Centre:Gauhati University Centre |
Help need for designing UPDATE query :
-------------------------------------------------------------------------------- Hi all! Pl. help me in designing an UPDATE query in MS Access 2007. I have 2 tables. Table 1: tblMember(mid, sponsorid, mname) Table 2: tblCountMember(mid, sponsorid, totalCount) Here mid in both tables are primary and joined with 1-to-1 relationship. Each member has a sponsor and a member becomes sponsor for other members. I want a query which will count members under each sponsor and update totalCount field in table tblCountMember with one go. Here is an example how it will be looked after data entry. In tbleMember -
Thanks in advance. |
|||||||||||||||||||||||||||||||||
![]() |
![]() ![]() ![]() |