如何对下表执行连接操作?

时间:2017-12-21 08:29:24

标签: mysql

我是初学程序员。这是我的表结构:

Database structure

我想从'post'表中检索内容并输入字段,其中userdId跟在'following'字段后面。我正在尝试这个SQL Join来追踪追随者。

SELECT userId,following, userId,postId,content,file,type
FROM follow, post
WHERE userId = '5a37589e4ff8b'

1 个答案:

答案 0 :(得分:2)

您应该使用JOIN语法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <link rel="shortcut icon" href="" type="image/x-icon" />
    <script type="text/javascript">
        // Set timeout variables.
        var timoutWarning = 6000; // Display warning in 6 Sec.
        var timoutNow = 10000; // Timeout in 10 Sec.

        var warningTimer;
        var timeoutTimer;

        // Start timers.
        function StartTimers() {
            warningTimer = setTimeout("IdleWarning()", timoutWarning);
            timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
        }

        // Reset timers.
        function ResetTimers() {
            clearTimeout(warningTimer);
            clearTimeout(timeoutTimer);
            StartTimers();

        }

        // Show idle timeout warning dialog.
        function IdleWarning() {
            alert("COntact your admin");
        }

        // Logout the user.
        function IdleTimeout() {
            window.location = "#";
        }
    </script>
</head>
<body onload="StartTimers();" onmousemove="ResetTimers();">
    <form id="form1" runat="server">
    <div id="timeout">
        <h1>
            Session About To Timeout</h1>
        <p>
            You will be automatically logged out in 1 minute.<br />
        To remain logged in move your mouse over this window.
    </div>
    <table id="table1" align="center" border="1" width="800" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                Hello World
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
相关问题