SQL INNER JOIN不会回报我需要的东西

时间:2014-03-23 18:22:36

标签: mysql sql

$rs25 = $connector->query("
    SELECT * FROM
    (SELECT content.*,topics.title AS topi2 FROM content 
      INNER JOIN topics 
      ON topics.id=content.topic) a
    WHERE a.user='$sf' ORDER BY a.date DESC");

我认为问题在于这种语法。我想做的是SELECT topics.title WHERE content.topic=topics.id并按content.date (DATETIME) DESC排序 或者也许我没有使用正确的加入?谢谢。

1 个答案:

答案 0 :(得分:0)

您的问题中的子查询实际上不需要执行以下操作:

SELECT content.*,topics.title AS topi2 
FROM content  INNER JOIN topics 
ON topics.id = content.topic
WHERE content.user='$sf' 
ORDER BY content.date DESC