This query sets the value of a local variable in a select statement:
select @tid = title_id from titles where type = "business"
The where clause matches multiple rows in the titles table. so the local variable is always set to the value from the last matching row returned by the query. The value is always the same in serial processing, but for parallel query processing, the results depend on which worker process finishes last. To achieve a consistent result, use a clause that performs a final sort step, execute the query in serial mode, or add clauses so that the query arguments select only single rows.