V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yoyicue
V2EX  ›  Python

SQLAlchemy Query 请教

  •  
  •   yoyicue ·
    yoyicue · 2012-03-19 18:06:35 +08:00 · 3890 次点击
    这是一个创建于 4414 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Post 是 SQLAlchemy Model (对应 posts 表)
    Tag 也是 SQLAlchemy Model (对应 tags 表)
    post_tags 是关联上面两个 Model 的 Many-to-Many 的表

    请问
    从 posts 取出用于 posts.flag == 1 的 tags 全集
    如何用 SQLAlchemy Query 表达

    SELECT name
    FROM tags
    WHERE id
    IN (
    SELECT b.tag_id
    FROM posts a, post_tags b
    WHERE a.id = b.post_id
    AND a.flag =1
    );

    3 条回复    1970-01-01 08:00:00 +08:00
    yoyicue
        1
    yoyicue  
    OP
       2012-03-19 18:11:55 +08:00
    @livid
    v2ex 的 gist 支持坏掉了?
    对于外部内容的支持 比如 weibo 的图床等等
    缺少一个 help 页面 FAQ 的内容太老了.
    Livid
        2
    Livid  
    MOD
       2012-03-19 18:14:00 +08:00
    今天下午在修改 https 支持的时候带来的新问题。

    正在解决。稍等。
    Livid
        3
    Livid  
    MOD
       2012-03-19 18:29:00 +08:00
    现在好了。

    话说 gist 实在是太卡了。考虑是不是自己为它搭一个反向代理加速好了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2586 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:28 · PVG 23:28 · LAX 08:28 · JFK 11:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.