No Subject....

From: Date: Wed, 14 Feb 2024 14:16:10 +0000
Subject: No Subject....
Groups: php.db 
Request: Send a blank email to php-db+get-4664@lists.php.net to get a copy of this message
Hej All! Which is the best way to discover if a entry on a MySQL table must be updated or created? Example: Suppose I have a table called products and on this table I am going to save information about product's forecast using fields 'name', 'mont_year' and 'quantity'. In some situations it will be necessary to update fields (client has decided to change quantities for a specific product and month already defined on the forecast) and in others it will be necessary to add a new entry (client added a new month or product on the forecast - the period covered with this forecast tool advances in time according to the month). If I use update for every variable of this form (the main interface is obviously a form) then what didn't exist before will continue not to exist and probabily I'll receive some error messages from MySQL regarding the update of fields that don't match the specified criteria. If I use insert I'll have double or even triple entries for certain products on the same month, but by the same time I'll be able to include the new ones. Do you have some ideas about the best approach for this problem or it's just matter of making comparisions between queries? Best regards, Fábio Ottolini _______________________________________________________ Processed by the Eletronic.Net Web Mail Program

« previous php.db (#4664) next »