GreenSmurf Posted May 23, 2008 Share Posted May 23, 2008 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 can you show an example using example data? Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted May 23, 2008 Author Share Posted May 23, 2008 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 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. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted May 23, 2008 Author Share Posted May 23, 2008 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 29, 2008 Share Posted May 29, 2008 I don't know what you mean by "create group" in the sql sense. Quote Link to comment Share on other sites More sharing options...
GreenSmurf Posted June 4, 2008 Author Share Posted June 4, 2008 I will get an example up soon. Sorry, I had to get some other stuff done with the DB first. -Brandon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.