Jump to content

Counting Words across two fields


donmouth

Recommended Posts

Sorry if this is very basic.

 

We have our church membership lists in a MySQL database with the following fields:

 

Surname

Person1

Person1_Membership

Person2

Person2_Membership

...

 

The membership fields will either be empty or contain "Resident" or "Non-Resident". The reason for two columns is that some couples may only have one partner as a member.

 

I am trying (without success) to find a way of getting a total (to display on a web page) of how many "Resident" and how many "Non-Resident" members we have. In other words, I'm trying to get a sum of the total number of times "Resident" and and total number of times "Non-Resident" appears in the two columns combined.

 

(hope that makes sense!)

 

I would appreciate any pointers from anyone who has managed to do this, or something similar, already.

 

Many thanks for the help

Link to comment
Share on other sites

Why not create a separate row for each, but store their resident status in a field of it's own? You could link to the other partner with a "parent" record:

 

ID | Surname | Firstname | Resident | Parent

1  | Smith  | John      | 1        | null

2  | Smith  | Linda    | 0        | 1

 

This would make such calculations a lot easier.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.