Home >Backend Development >PHP Tutorial >帮忙看个SQL有关问题

帮忙看个SQL有关问题

WBOY
WBOYOriginal
2016-06-13 12:10:17852browse

帮忙看个SQL问题

<br />SELECT ornamentation_images.ismark ismark,ornamentation_images.width width,ornamentation_images.height height,users.nickname name,ornamentations.id id,ornamentations.image_name image_name,ornamentations.image_url image_url,ornamentations.add_author add_author,ornamentations.browse_real_cnt browse_real_cnt,ornamentations.comnum comnum,users.head head,users.comnum unreadFROM `ornamentation_images` <br />LEFT JOIN users on ornamentation_images.add_author=users.id <br />LEFT JOIN ornamentations on ornamentation_images.ornamentation_id=ornamentations.id <br />WHERE ( ornamentations.enable = 0 ) AND ( ornamentations.checkstatus = 2 ) <br /> ORDER BY ornamentations.id desc LIMIT 0,5<br />

能查出来结果,只是没有查出来users表里的数据,问题出在哪?
------解决思路----------------------
表结构在哪呢
------解决思路----------------------
可能是left join 的问题
left join是以左表的记录为基础的,ornamentation_images可以看成左表,users可以看成右表,left join是以左表为准的.
换句话说,左表的记录将会全部表示出来,而右表只会显示符合搜索条件的记录,右表记录不足的地方均为NULL.

楼主可以查看一下,是否这个原因呢

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn