Re: [PHP-DB] how to make multiple in a coloum in mysql DB

2002-03-06 Thread DL Neil

Yoga,
wa aleikum as-salaam (tr: greetings returned to you)

> salam,
> i'm make a database in mysql, example :
> namescore Ascore A   Total
> john  7890
> mike  9070
> etc...
> ask me is:
> how to make multiple or total in coulum "Total"
> otomatically, if me input score in coulom total.
> please help me...
> (i am sorry my english)


Please don't feel it necessary to apologise for language difficulties.
The list language is English - and yet most of the MySQL AB people don't
speak English as their native-tongue, so ...

May I assume that the second 'score' column is labeled 'score B'?

There are two answers!

The answer to your specific question is that when you gather the data
(presumably an HTML form to PHP), after data-verification checks on
$scoreA and $scoreB, compute:

$total = $scoreA + $scoreB;

then formulate the INSERT statement accordingly.

However unless there are clear performance reasons for doing this, you
should not store "Totals" in a relation/table because the values in this
column are derived (and re-derivable) from the scores - and every time
you add a new score, the Total column would need to be changed. Better
to (only) store the scores in the table, and calculate the totals when
you retrieve the records later, eg

SELECT name, scoreA, scoreB, scoreA+scoreB AS Total FROM...

Unfortunately that comment on 'normalising' the table may also apply to
the scores themselves - should each score/result be held on its own row,
rather than having x-columns across the table. SQL/relational theory
doesn't work well this way around ('across', it prefers to go 'down') -
but that's another question.

Fee aman 'illah, (tr: go with God)
=dn


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] how to make multiple in a coloum in mysql DB

2002-03-06 Thread Markus Lervik

On Wed, 2002-03-06 at 10:02, Yoga Anak Medan wrote:
> salam,
> i'm make a database in mysql, example :
> namescore Ascore A  Total
> john  7890
> mike  9070
> etc...
> ask me is:
> how to make multiple or total in coulum "Total"
> otomatically, if me input score in coulom total.
> please help me...
> (i am sorry my english)

INSERT INTO table VALUES("john", "78", "90", scoreA+scoreB);


Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] how to make multiple in a coloum in mysql DB

2002-03-05 Thread Yoga Anak Medan

salam,
i'm make a database in mysql, example :
namescore Ascore ATotal
john  7890
mike  9070
etc...
ask me is:
how to make multiple or total in coulum "Total"
otomatically, if me input score in coulom total.
please help me...
(i am sorry my english)


yoga


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php