How to select from a row using the “like” query in sqlite?

I have this line of code that gets a record from a row.

function getMoveVolume ( item )  
 tempItem = {}  
 for row in db:nrows ( "SELECT \* FROM table WHERE itemname = '" .. item .. "'" ) do  
 local rowData = row.itemdesc  
 tempItem[#tempItem+1] = rowData  
 end  
 return tempItem  
  
end  

how can I get the data using the “like” query instead of getting the itemdesc based from the itemname. I should get the itemdesc as long as it contains any value from the item parameter. [import]uid: 189861 topic_id: 34733 reply_id: 334733[/import]

You use ‘%’ as a wildcard with LIKE.

If itemname should *begin* with the passed item:

SELECT \* FROM table WHERE itemname LIKE '" .. item .. "%'"

… and if item can be anywhere in itemname:

SELECT \* FROM table WHERE itemname LIKE '%" .. item .. "%'"

[import]uid: 70847 topic_id: 34733 reply_id: 138033[/import]

Thanks will try this. [import]uid: 189861 topic_id: 34733 reply_id: 138183[/import]

You use ‘%’ as a wildcard with LIKE.

If itemname should *begin* with the passed item:

SELECT \* FROM table WHERE itemname LIKE '" .. item .. "%'"

… and if item can be anywhere in itemname:

SELECT \* FROM table WHERE itemname LIKE '%" .. item .. "%'"

[import]uid: 70847 topic_id: 34733 reply_id: 138033[/import]

Thanks will try this. [import]uid: 189861 topic_id: 34733 reply_id: 138183[/import]