Closed Thread Icon

Preserved Topic: Need help with complex SELECT statement via PHP (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12271" title="Pages that link to Preserved Topic: Need help with complex SELECT statement via PHP (Page 1 of 1)" rel="nofollow" >Preserved Topic: Need help with complex SELECT statement via PHP <span class="small">(Page 1 of 1)</span>\

 
acidbox
Bipolar (III) Inmate

From: purgatory
Insane since: Mar 2001

posted posted 06-16-2002 22:52

Here is what I am doing.

I am using a mysql database to log each time a user uses a section on my website.

So, for each time a user enters a certain seciton on the website, a record is created in the database. It stores the user's name, the account number that the user is a part of, and a 0 or 1 flag to determine if a user took advantage of the feature.

Lets say, for instance, there are 2 sections.

For the 4 users of account number 15, they collectivley go to section one 3 times and section two 4 times.
Account number 14 goes to section number one 1 time and section number two 1 time.
Account number 12 goes went to section number one 0 times and section number two 1 time.

The mySQL table (records) will have 10 records similar to the following:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
------------------------------------

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-17-2002 03:18

acidbox: My first feeling is that things would be easier with a different DB structure. For the table that logs these things I'd go with something like:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
user_id

acidbox
Bipolar (III) Inmate

From: purgatory
Insane since: Mar 2001

posted posted 06-17-2002 05:09

that is a really good idea. I'll have to try it. Thanks for the heads up!

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-17-2002 12:09

acidbox: I was tired when I wrote that but it seems OK if a little brief. Have a go and get back to us if you have any problems - the SQL does get a bit more complex but its not rocket science

___________________
Emps

FAQs: Emperor

stinx
Bipolar (III) Inmate

From: London, UK
Insane since: Apr 2002

posted posted 06-17-2002 14:28

The SQL for this isn't too complex...

SELECT acct_num, sum(sec_1), sum(sec_2) FROM records GROUP BY acct_num


acidbox
Bipolar (III) Inmate

From: purgatory
Insane since: Mar 2001

posted posted 06-17-2002 20:13

well damn. That was even easier.. lol...thanks stinx.

Rahly
Bipolar (III) Inmate

From: Michigan
Insane since: Jul 2002

posted posted 07-06-2002 19:20

SQL is your friend!

Rahly

« BackwardsOnwards »

Show Forum Drop Down Menu