Jump to content

Intuitive Grouping


GreenSmurf

Recommended Posts

I would like to know how to create an intuitive grouping list in mysql

Example-

if ((lastname=same_lastname and firstname=last_firstname) or businessname=same_businessname)

{

  create group based off of business/lastname, firstname

}

 

Could anyone give me an idea where to start?

 

-Brandon

Link to comment
Share on other sites

Not really I haven't quite started but I would like it to function like this:

 

[bob]  [smith]  [Crayola]

[John] [Doe]    [bubbleGum]

[bob]  [smith]  [bubbleGum]

 

Then the query should find all instances of Bob Smith and create a group named Bob Smith and associate the row of data in the db with the group name.

Also, it should find the business name BubbleGum and create a group named BubbleGum and associate the row of data in the db with the group name. So I am thinking that nameID and businessID would both be necessary to track said groups.

 

-Brandon

Link to comment
Share on other sites

Okay I'm not quite sure I'm understanding this 100% but it seems to me that what you are saying is that for each row of your table, you want it to look like this, right?

 

 

     

Group1FirstNameLastNameBusinessNameGroup2

 

 

     

BobSmithBobSmithCrayolaCrayola

 

 

     

JohnDoeJohnDoeBubbleGumBubbleGum

 

 

     

BobSmithBobSmithBubbleGumBubbleGum

 

 

If that is the case, first off, I don't really see why you would need the Group2 column, as it is virtually identical to the businessname column...2nd, Group1 would be made simply by concatonating your Firstname and Lastname variables.  I don't really know how you have anything else setup, but it seems you would do that in the information entering process, in the part of your script that creates the new entry; just make a new temp var $group1 = $firstname . $lastname; etc...

 

if that's not what you're saying then..uh, please elaborate further.

Link to comment
Share on other sites

Well, there is over 1200 people listed in the address book. So, I would like it to skip peope that are listed only once and I would like groups of business and persons because some people are associated with multiple businesses or some businesses are associated with muliple peoples.

 

I would also like it to check if the group already exsists and add the person/business without creating a new one necessarily.

 

-Brandon

Link to comment
Share on other sites

hrmm..okay, so you already have a database, and you are wanting to phrase a query to pull specific information based on your criteria?  I mean, I could help you on some php code to sort through it all if you do a query for everything first, but that's not really efficient.  I think you'll probably find the sql forum more useful so I'm going to go ahead and move your thread over there.  One of the resident database experts should be able to help you out there.

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.