[英]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';
I have two tables
one for category
and second
for saving images
with category name my query is here Then executing thien shows MySQ
L returned an empty result set (ie zero rows). 我有
two tables
一个用于category
, second
用于saving images
具有类别名称的saving images
,我的查询在这里,然后执行thien显示MySQ
L返回了一个空结果集(即零行)。 (Query took 0.0007 seconds.) (查询花费了0.0007秒。)
Remove single quotes in name instead of 'name' read when to use single quotes, double quotes, and backticks 使用单引号,双引号和反引号时,请删除名称中的单引号,而不是“名称”
If you put single quotes on table or column name, they are treated as string so don't put. 如果将单引号放在表名或列名上,它们将被视为字符串,因此请勿放置。
SELECT `name`
FROM tbl_gallery
JOIN tbl_gallery_category ON tbl_gallery.name = tbl_gallery_category.gallery-cat-id;
Note : 注意 :
where 'name' = 'gallery-cat-id';
above where condition is always false only. 以上条件始终始终为假。 Because your just comparing 'name' is equal to 'gallery-cat-id' so that it's false .
因为您刚刚比较的“名称”等于“ gallery-cat-id”,所以它是false。
Don't use quotes on table or column names. 不要在表名或列名上使用引号。
SELECT name
from tbl_gallery
join tbl_gallery_category on tbl_gallery.name = tbl_gallery_category.`gallery-cat-id`
If you need to escape a column name then use backticks. 如果需要转义列名,请使用反引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.