简体   繁体   English

SQL查询无法正常工作

[英]SQL query doesn't work as expected

I have 3 tables: 我有3张桌子:

MENU 菜单
m_id
m_name (menu name) m_name(菜单名称)
m_content (content of the page) m_content(页面内容)
m_p_id (plugin id) m_p_id(插件ID)
m_s_id (status id) m_s_id(状态ID)

PLUGINS PLUGINS
p_id P_ID
p_name (plugin name, for example Gallery) p_name(插件名称,例如Gallery)
p_file (gallery.php) p_file(gallery.php)

STATUS 状态
s_id S_ID
s_name (active or passive) s_name(主动或被动)

I would like to see these in an HTML table: 我想在HTML表格中看到这些:
m_id
m_name m_name
m_content m_content
p_name p_name
s_name S_NAME

This is my query: 这是我的查询:

SELECT m_id, m_name, m_content, s_name,p_name
        FROM menu, status, plugins
        WHERE m_s_id=s_id AND m_p_id=p_id

The problem is, that I can't see the rows, where the m_p_id is empty(NULL in the column). 问题是,我看不到行,其中m_p_id为空(列中为NULL)。

try that: 尝试:

SELECT m_id, m_name, m_content, s_name, p_name
FROM menu
LEFT JOIN status ON m_s_id=s_id
LEFT JOIN  plugins ON m_p_id=p_id

You can't 你不能

Because you need to JOIN those tables 因为你需要加入那些表

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

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