Re: question about columns in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



as suggested not to create a field which would add the numeric 
values in the tables, i used the select sum query however it does 
not work.
The table has 2 fields defined as aboutus & contactus as integer. In 
this case as i will be updating the columns every time there is a 
visit, this table will only have 1 row at all times. Is it because 
of this the query is not being executed.

$count="SELECT SUM(aboutus, contactus) FROM visits"; 
mysql_query($count);

This query is not being executed.

please advice.

--- In php-objects@xxxxxxxxxxxxxxx, sudhakar <finals27@...> wrote:
>
> Thanks.
> --- Pete <cgrp@...> wrote:
> 
> > In message <fgj5kv+n32c@...>, Sudhakar
> > <finals27@...>
> > writes
> > >my question is when i create the table can i create
> > the last column in 
> > >a way that would add all the numeric values of the
> > remaining field 
> > >names. This would avoid me to run an sql query from
> > a php file to view 
> > >this information.
> > 
> > You mean, add a column that automatically adds the
> > other fields
> > together?  The answer to that is no.
> > 
> > Also, it goes against the principle of good database
> > design, where the
> > data should be stored once, and once only.  You
> > would be storing the
> > data once in the individual fields, and again in the
> > total field.
> > 
> > >Ex: Create table tablename(aboutus int(11),
> > contactus int(11), 
> > >totalvisits int(11));
> > 
> > This is not the best layout, because if you add any
> > new pages, you would
> > have to change the table layout.
> > 
> > Better is
> > Create table tablename(pagename char(20), visitcount
> > int(11));
> > and use the SUM command to get the total visits.
> > 
> > -- 
> > Pete Clark
> > 
> > Sunny Andalucia
> > http://hotcosta.com/Andalucia.Spain
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com
>



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux