MySql SQL_NO_CACHE Problem between 5.0 and 5.5

The following query works in MySql 5.0

SELECT SQL_NO_CACHE
    ItemId,
    AnotherColumn
FROM
    TableOne
UNION
SELECT SQL_NO_CACHE
    ItemId,
    AnotherColumn
FROM
    TableTwo

But in MySql 5.5 I get the following error:

MySql.Data.MySqlClient.MySqlException: Improper use / allocation of 'SQL_NO_CACHE'

What is the proper placement of SQL_NO_CACHE queries for UNION?

If I put SQL_NO_CACHE on one side of UNION, will it affect both sides?

+3
source share
1 answer

As in MySql 5.5.3, you just need to specify SQL_NO_CACHE in the first SELECT query for UNION:

SELECT SQL_NO_CACHE
    ItemId,
    AnotherColumn
FROM
    TableOne
UNION
SELECT
    ItemId,
    AnotherColumn
FROM
    TableTwo

It applies to the entire request. If you try to specify it in subsequent SELECT statements, this will result in an error (and now it is also allowed in subqueries).

+5
source

All Articles