# I can't seems to run two statements

**URL:** <https://www.five.org/t/i-cant-seems-to-run-two-statements/219>\
**Category:** How do I?\
**Tags:** how-to\
**Created:** [June 6, 2023, 8:32am UTC](https://www.five.org/t/i-cant-seems-to-run-two-statements/219 "2023-06-06T08:32:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![temitope](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@temitope](https://www.five.org/u/temitope)\
**Post date:** [June 6, 2023, 8:32am UTC](https://www.five.org/t/i-cant-seems-to-run-two-statements/219/1 "2023-06-06T08:32:52Z")

</div>

Hi everyone! I am trying to combine the SELECT and UPDATE query but it’s not working. I want to use the SELECT query to retrieve the result and execute the UPDATE query using the retrieved values.

When I tried to save it, I got this pop-up error:

> Unsupported query definition, StatementCount: 2, SetCount: 0

Is there any way around this?

Thanks in anticipation.

---

<div class="post-metadata">

**Author:** ![mark](https://yyz2.discourse-cdn.com/flex030/user_avatar/www.five.org/mark/32/300_2.png) [@mark](https://www.five.org/u/mark)\
**Post date:** [June 6, 2023, 9:49pm UTC](https://www.five.org/t/i-cant-seems-to-run-two-statements/219/2 "2023-06-06T21:49:47Z")

</div>

Hi Temitope,

I probably need a little more information to answer this fully but Five does support UPDATE SQL commands based on a SELECT.

For example if you are trying to achieve eeverything in one query you could execute:  
UPDATE  
User  
SET  
LastAccessDate = (SELECT MAX(AccessDate) FROM LogFile WHERE LogFile.UserKey = User.UserKey);

If you are using queries inside logic it would require a five.executeQuery() command for the SELECT statement and then a loop going through the results executing another five.executeQuery() with the UPDATE statement for each record you wanted to update.

Hope this helps but let me know if you need more information.

Mark

---

<div class="post-metadata">

**Author:** ![temitope](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@temitope](https://www.five.org/u/temitope)\
**Post date:** [June 7, 2023, 10:44am UTC](https://www.five.org/t/i-cant-seems-to-run-two-statements/219/3 "2023-06-07T10:44:08Z")

</div>

I switched to running the query inside the logic using the five.executeQuery() and it’s working fine now. Thanks.
