SQL Syntax to limit returned results

Hi, I’m, a relative beginner with Python, know next to nothing about SQL and am trying to figure out how to limit the number of rows returned in base.query(). So far, I have not been able to figure it out from the documentation, forum search or trying different SQL commands found on the web.
Scenario: I am building a base where items can be loaned for a certain amount of time. I need the query to return just only one of the available items from the inventory list and link it with the request.
I build a query string as follows and use it with base.query(): query_string = "SELECT _id FROM Inventory WHERE ArticleType= \"%s\"" % (item)
It returns all the row IDs for available items and I could just use Python to pull a an item from the results. But since we are running a self-hosted instance, I would like to be more efficient with our processor cycles.
And yes, I am aware that I could achieve this with a protected view and and base.get_rows(). I’m just trying to implement this with pure scripting.

I managed to figure it out myself. I just had to append LIMIT 1 to my query string. It was just too obvious.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.