【发布时间】:2013-12-04 01:31:01
【问题描述】:
我无法弄清楚最简单的事情。尝试了各种事情,但没有成功。我想简单地从表中选择一个具有特定名称的团队。此代码将只返回表的标题,并且不会打印任何内容,就好像我的查询是空的一样。
我尝试过以不同的方式更改引号,但它要么给我一个错误,要么什么也不打印。
SELECT * from League where Name='AS Roma'
SELECT * from League where Name=AS Roma
SELECT * from League where Name="AS Roma"
有人知道吗?
$db = new SQLite3('test.db');
$results = $db->query('SELECT * from League where Name="AS Roma"');
echo "<table border='1'>";
echo "<tr>";
echo "<th>Position</th><th>Club Name</th><th>G</th><th>W</th><th>D</th><th>L</th><th>GF</th><th>GA</th><th>P</th>";
echo "</tr>";
while ($row = $results->fetchArray()) {
echo "<tr>";
echo "<td>", $row[0], "</td><td>", $row[1],"</td>", "<td>", $row[2], "</td><td>", $row[3],"</td>","<td>", $row[4], "</td><td>", $row[5],"</td>", "<td>", $row[6], "</td><td>", $row[7],"</td>", "<td>", $row[8], "</td>";
echo "</tr>";
}
echo "</table>";
echo '<br>';
【问题讨论】:
-
您确定您的数据库中有一个值为
"AS Roma"的字段吗?返回 0 行的查询不是错误。 -
是的,当然,这不是问题。我知道,因为它返回空,这意味着找不到它,但它就在那里。我以为我有语法问题
-
如果我在 SELECT * FROM League where Name='SS Lazio' 之后直接在 SQLite 管理器中输入,它仍然会给我一个空的东西,但它就在那里
-
什么是 SELECT * FROM League;打印?
-
包含内容的整个表格