How to find and update the next record in a linking table

Posted by someoneinomaha on Stack Overflow See other posts from Stack Overflow or by someoneinomaha
Published on 2010-05-22T15:01:35Z Indexed on 2010/05/22 15:21 UTC
Read the original article Hit count: 177

Filed under:
|

I have a classifieds system I'm working on.

People are able to add photos to a classified, but I only display one when displaying the list of classifieds.

To do that, I have a linking table between classifieds and photos that has a "is_main" boolean field.

When someone deletes one of their classified photos, I want to:

1) See if there is more than that photo tied to the classified.
2) If there is, update the next photo and set that "is_main" field to TRUE.

Just trying to find out the most efficient way to do this.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about codeigniter