如何从表名称中包含空格的表中选择数据? [英] How to select data from a table where the table name has blank spaces in?
本文介绍了如何从表名称中包含空格的表中选择数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一种情况,我有一个名为'Master File'的mySql表,其中包含6000条记录.
I have a situation, I have a mySql table named 'Master File' with contains 6000 records.
但是我收到一个错误Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
我的代码如下.
$sql = "SELECT * FROM Master File";
$results = mysql_query($sql);
//Looping threw the Master File
while($row = mysql_fetch_array($results)){
print_r($row);
}
推荐答案
$sql = "SELECT * FROM `Master File`";
您需要在带有空格的字段名称前后打勾.
You need back ticks around fieldnames that have spaces.
这篇关于如何从表名称中包含空格的表中选择数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文