0
$sql="select last_logged_out_at from `users`";
$sql.="WHERE xxxxxxx = '11112000'";
$rslt=mysql_query($sql);
$row=mysql_fetch_array($rslt);
print_r($row);

不工作的“条件”;如果我删除 where 然后它从表中获取数据并且如果我将条件更改为表中的其他值,那么它也可以工作。特定列“xxxxxxx”此查询不起作用请帮助我..

4

6 回答 6

4

在第一行的结尾和第二行的开头之间没有空格:

$sql.=" WHERE xxxxxxx = '11112000'";

于 2013-02-05T10:41:09.887 回答
2

我认为这是因为“用户”和“WHERE”之间没有空格。

于 2013-02-05T10:42:28.683 回答
1

因为 db 列"xxxxxxx"(您在WHERE子句中使用)是 MySQL 关键字。所以,使用:

WHERE `xxxxxxx` = '11112000' 

代替

WHERE xxxxxxx = '11112000'
于 2013-02-05T10:49:06.360 回答
0

您还可以在单​​个 sql 中编写查询。

$sql="select last_logged_out_at from users WHERE xxxxxxx = '11112000'";
于 2013-02-05T10:45:44.090 回答
0
$sql="select last_logged_out_at from `users` "; //enter a space after `users`
$sql.=" WHERE xxxxxxx = '11112000'"; // or enter a space before WHERE
于 2013-02-05T10:49:49.297 回答
0

更改数据库中的列名。名称包括像'_'这样的符号,所以它不会冲突。

于 2013-02-05T11:19:56.520 回答