I am storing cache information from the cache server if application version is matching else I need to set cache details as NULL.
Currently I am doing it like this
UPDATE
cache_table
SET
_data = NULL
WHERE _id = id AND _app_version != "current_version"
Followed by select query
SELECT
_data
FROM
cache_table
WHERE _id = id AND _app_version == "current_version"
Is there a way I can do required update and select in one query without firing two query ?
Note: I don’t want to use MySQL procedure. No specific reason but don’t want to store application logic in DB so I can easily change database application.
Generally
UPDATEandSELECTare two distinct operations. The only way to combine them is with a stored procedure as you identify.