Question: I'm developing for iOS using XCode, and basically what the action my button is doing is I click the button, a sound plays for about 5 seconds, and the image of the button changes when I click it as well. So a sound plays and an Image changes at the same time. Here's the problem I'm having.

When I press the button the image changes for a second, and only stays changed if you hold your finger on it.

I have an outlet set up where I set

`button.selected= YES`

then

`button.selected= NO`

or "highlighted" in place of "selected" either way it results in one of two things. The new image that was intended to switch to on touch is now the "default" displayed, since setting it to "YES" first causes that, or it continues to do the same as above, only changing for a second.

Is there anything I can do to set the duration time of it being highlighted or selected to 5 seconds after being touched so that way it changes on touch and doesn't change back until the sound is finished?

-Extra stuff:
I'm using the Audio Toolbox framework for the sound code, and ARC is enabled.

Thanks as always!

Answer: 
Use `NOT EXISTS`:

```
SELECT up1.* 
FROM   user_preferences up1 
WHERE  ( NOT EXISTS(SELECT 1 
                    FROM   user_preferences up2 
                    WHERE  user_id = {userIdVar}) 
         AND user_id IS NULL ) 
        OR ( user_id = {userIdVar} ); 

```
This should work to select the first row that is either NULL or set the the user\_id variable where the user\_id variable is preffered if both are set and then shows every preference\_name only once.

```
SELECT
  *
FROM 
  (
    SELECT
      *
    FROM
      user_preferences
    WHERE
      user_id = {userIdVar} OR
      user_id IS NULL
    ORDER BY
      CASE WHEN user_id IS NULL THEN 1 ELSE 0 END
  ) sub_query
GROUP BY
  preference_name

```

**[SQL FIDDLE](http://sqlfiddle.com/#!2/68627/4)**