avoid incompatible query when not using MySQL (fixes #3661, BP from #1984)

Bug ticket
https://redmine.openpne.jp/issues/1984
BP ticket
https://redmine.openpne.jp/issues/3661