MySQL Forums
Forum List  »  Newbie

Re: multiple records single value
Posted by: Andrew Gilfrin
Date: July 22, 2005 06:28AM

Yep use an IF statement in the update like so,


mysql> update photos set default_val = if (file_id = '3udu',1,0) where property_id = 1;

Query OK, 1 row affected (0.05 sec)
Rows matched: 3 Changed: 1 Warnings: 0

mysql> select * from photos;
+------+---------+-------------+-------------+
| id | file_id | default_val | property_id |
+------+---------+-------------+-------------+
| 1 | 3434 | 0 | 1 |
| 2 | 343c | 0 | 1 |
| 3 | 3udu | 1 | 1 |
+------+---------+-------------+-------------+
3 rows in set (0.00 sec)

Andrew Gilfrin
------------------
http://gilfster.blogspot.com
My MySQL related Blog

http://www.mysqldevelopment.com
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Options: ReplyQuote


Subject
Written By
Posted
Re: multiple records single value
July 22, 2005 06:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.