繁体   English   中英

我想从一个表中选择名称并显示在我的页面中

[英]i want select name form one table and display in my page

SELECT name from tbl_gallery, tbl_gallery_category where 'name' = 'gallery-cat-id';

我有two tables一个用于categorysecond用于saving images具有类别名称的saving images ,我的查询在这里,然后执行thien显示MySQ L返回了一个空结果集(即零行)。 (查询花费了0.0007秒。)

使用单引号,双引号和反引号时,请删除名称中的单引号,而不是“名称”

如果将单引号放在表名或列名上,它们将被视为字符串,因此请勿放置。

SELECT `name` 
FROM tbl_gallery 
JOIN tbl_gallery_category ON tbl_gallery.name = tbl_gallery_category.gallery-cat-id;

注意 :

where 'name' = 'gallery-cat-id';   

以上条件始终始终为假。 因为您刚刚比较的“名称”等于“ gallery-cat-id”,所以它是false。

不要在表名或列名上使用引号。

SELECT name 
from tbl_gallery
join tbl_gallery_category on tbl_gallery.name = tbl_gallery_category.`gallery-cat-id`

如果需要转义列名,请使用反引号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM