Adding to a record

2004-05-25 Thread Daniel Venturini
Hello. Quick easy question I think? I display a INT value to a page (php) by
querying mysql. I want to be able for someone to put a new number and add to
that record. How would I go about doing this. Would this be a mysql command
or a php thing? Thanks in advance.


Re: Adding to a record

2004-05-25 Thread Sarix
You might want to acctuly read through the documentation, or get a book on
php/mysql.

But you would send to the query:

UPDATE 'table' SET number='value' WHERE id=what ever that rows id is

- Original Message - 
From: Daniel Venturini [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 25, 2004 7:04 PM
Subject: Adding to a record


 Hello. Quick easy question I think? I display a INT value to a page (php)
by
 querying mysql. I want to be able for someone to put a new number and add
to
 that record. How would I go about doing this. Would this be a mysql
command
 or a php thing? Thanks in advance.




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Adding to a record

2004-05-25 Thread Michael Kruckenberg
Seems like you could do it either way:
PHP
?
$new_num = $mysql_num + $user_num;
mysql_query(update table set number = $new_num where . . .)
?
or
MySQL
?
mysql_query(update table set number = number + $user_num where...)
?
Depends if you want php or mysql to perform the calculation.
Daniel Venturini wrote:
Hello. Quick easy question I think? I display a INT value to a page (php) by
querying mysql. I want to be able for someone to put a new number and add to
that record. How would I go about doing this. Would this be a mysql command
or a php thing? Thanks in advance.
--
http://mike.kruckenberg.com | [EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Looking up duplicate record or adding new unique record

2003-07-23 Thread Phil Bitis
CREATE TABLE tbllayer (
  LayerID int(11) NOT NULL default '0',
  LayerSize int(11) NOT NULL default '0',
  IceTypeID int(11) NOT NULL default '0',
  Fingerprint char(16) binary default NULL,
  PRIMARY KEY  (LayerID),
  UNIQUE KEY Fingerprint (Fingerprint),
  KEY IceTypeID (IceTypeID)
) TYPE=MyISAM;

We have an internet monitoring application which stores objects in the above
table, with the fingerprint an MD4 of the object. In general about 30% of
the time an object monitored is already in the table, in which case we don't
want to re-insert it, we just want to find out it's ID. The percentage may
vary between 10% and 50% though.

Currently we have a cache in our application which works like this:

- object is monitored and its fingerprint taken
- is the fingerprint in the cache? if so, take its ID from there
- if not, do a SELECT on the table - if a match is found add it to the cache
and use its ID
- if not, INSERT the record into the tablem use its ID and possibly add it
to the cache too

Ok. In general, is it better to:

- do a SELECT to see if the record exists and if not INSERT it
or
- do an INSERT, and if it fails then do a SELECT to locate the record

What about if the duplicate ratio is high or low?

Cheers,
-Phil





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



UPDATE command, adding to exisiting record

2001-12-28 Thread Todd Williamsen


I am looking to update a record in a table, but take the exsisting value and
adding the new value to it...

I.e.

Exsisting record = 150, new record being inputed = 250 for a total of 400 to
be entered into the database.

I have looked at the man pages on this but all it gives is static numbers, I
need something that is being fed from a form and the new values will always
be different.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: UPDATE command, adding to exisiting record

2001-12-28 Thread Chris Bolt

 I am looking to update a record in a table, but take the 
 exsisting value and adding the new value to it...
 
 I.e.
 
 Exsisting record = 150, new record being inputed = 250 for a 
 total of 400 to be entered into the database.

UPDATE table SET row = row + 250 WHERE id = #;


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php