V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
imherer
V2EX  ›  程序员

请教各位大佬一个 SQL 写法

  •  
  •   imherer · Apr 23, 2019 · 822 views
    This topic created in 2565 days ago, the information mentioned may be changed or developed.

    有两张表,

    • 第一张star,字段:id、title
    • 第二张 unlock,字段id、uid、starid,其中 starid 就是 star 表中的 id

    逻辑就是当用户解锁一个 star 项的时候就会向 unlock 表里插入一条记录,同一个用户用一个 starid 只会有一条记录

    我现在想要的结果是根据 uid 为条件列出 star 表里的所有项,同时要知道每个项当前 uid 的用户是否解锁了

    用 LEFT JOIN 加上 where 之后就只会出 unlock 表里有条数了

    数据库是 postgresql

    另外:v 站的 markdown 编辑器不支持表格?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   804 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 86ms · UTC 22:33 · PVG 06:33 · LAX 15:33 · JFK 18:33
    ♥ Do have faith in what you're doing.