theo schrieb:
Hi
I' m a newbie and I'm sure this question has been answered many times, but
I can't find the appropriate thread.
Example:
I have a table of people's data including a field called say "importance"
like:
NAME; AGE; FUNCTION; IMPORTANCE
Peter; 24years, some job, 0
Anna; 22years, better job, 1
Frank; 40 years, chief, 2
Now, there is a new employee "John" with "a job better than Peter's"
His "importance" is one more than peter's, and all other move up +1;
So the list should look like this after inserting "John":
Peter; 24years, some job, 0
John; 28years, somewhat better job, 1
Anna; 22years, better job, 2
Frank; 40 years, chief, 3
Which is the most effiicient way (SQL Statements) to "insert" or
"delete" John in this example?
Thank you
Well one solution would be updating the table first
UPDATE workers SET impartance = importance + 1 WHERE importance > 1
This would raise every importance by one where the importance is bigger
than 1.
Now you could insert john with the importance of "1".
Is it that what you have been looking for?
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]