I have a function in MySQL that returns a list of integer values separated by a comma, thus forming a string.
e.g.
MyFunction(23);
Ret
You can use FIND_IN_SET function. For example:
SELECT FIND_IN_SET('34', '34,45,87,23,1'); -- return true
SELECT FIND_IN_SET('34', '34'); -- return true
SELECT FIND_IN_SET('34', ''); -- return false
In your case, the SQL query will look like:
SELECT id,
myItemId,
myItemValue,
myDateTime
FROM items
WHERE id IN
(SELECT MAX(id)
FROM items
WHERE myItemId=1
AND FIND_IN_SET(myItemValue, MyFunction(123))
GROUP BY myItemId);