Re: question about columns in a table

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

 



In message <fgj5kv+n32c@xxxxxxxxxxx>, Sudhakar <finals27@xxxxxxxxx>
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

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

  Powered by Linux