幫忙看個SQL有關問題

來源:互聯網
上載者:User
幫忙看個SQL問題

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`
LEFT JOIN users on ornamentation_images.add_author=users.id
LEFT JOIN ornamentations on ornamentation_images.ornamentation_id=ornamentations.id
WHERE ( ornamentations.enable = 0 ) AND ( ornamentations.checkstatus = 2 )
ORDER BY ornamentations.id desc LIMIT 0,5

能查出來結果,只是沒有查出來users表裡的資料,問題出在哪?
------解決思路----------------------
表結構在哪呢
------解決思路----------------------
可能是left join 的問題
left join是以左表的記錄為基礎的,ornamentation_images可以看成左表,users可以看成右表,left join是以左表為準的.
換句話說,左表的記錄將會全部表示出來,而右表只會顯示符合搜尋條件的記錄,右表記錄不足的地方均為NULL.

樓主可以查看一下,是否這個原因呢
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.