我在 MySQL 中运行它:
SELECT id, action FROM table1 WHERE action in ('α','δ','μ','Α','Δ','Μ')
请注意,这些字符是希腊语,而且我到处都在使用 utf-8。为什么此查询还返回 action = 'a' 或 'A' (latin) 的行?
这是整个脚本:
$query = "SELECT id, action FROM table1 WHERE action in ('α','δ','μ','Α','Δ','Μ') ORDER BY id ASC";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$totalRows_result = mysql_num_rows($result);
if($totalRows_result > 0) {
do {
$str = $row['action'];
$greek = array('α','δ','μ','Α','Δ','Μ');
$latin = array('A','D','M','A','D','M');
$validstr = str_replace($greek, $latin, $str);
$q = "UPDATE table1 SET action='$validstr' WHERE id='".$row['id']."'";
$res = mysql_query($q) or die(mysql_error());
} while ($row = mysql_fetch_assoc($result));
}