{"width":"100%","blog_url":"https://chyka.hatenablog.jp/","type":"rich","image_url":null,"title":"SQLAlchemy\u3067\"case\"","published":"2016-03-14 00:24:36","provider_name":"Hatena Blog","description":"SQLAlchemy\u3067case\u6587\u304c\u3064\u304b\u3048\u308b\u3002 case\u6587\u3068\u304b\u3053\u308c\u306e\u3053\u3068\u3002 CASE WHEN \u6761\u4ef6 THEN \u50241 ELSE \u50242 END \u7b2c\u4e00\u5f15\u6570\u306f\u5fc5\u9808\u3067\u3001\u6761\u4ef6\u3068\u3001\u305d\u308c\u304c\u771f\u3060\u3063\u305f\u5834\u5408\u306b\u8fd4\u3059\u5024\u306e\u30bf\u30d7\u30eb\u306e\u30ea\u30b9\u30c8\u3002 \u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570 else_ \u306f\u507d\u3060\u3063\u305f\u5834\u5408\u306b\u8fd4\u3059\u5024\u3002 \u6761\u4ef6\u306b\u306fand\u3001or\u6f14\u7b97\u304c\u4f7f\u3048\u308b\u3053\u3068\u306f\u78ba\u8a8d\u3057\u305f\u3002 IN \u3082\u4f7f\u3048\u308b\u304b\u3068\u601d\u3063\u305f\u3051\u3069\u3069\u3046\u3082\u60f3\u5b9a\u3069\u304a\u308a\u306e\u6319\u52d5\u3067\u306f\u306a\u3044\u3002\u5f8c\u3067\u8abf\u67fb\u3002 from sqlalchemy.sql.expression import case, and_, or_ \u5e74\u9f62\u304b\u3089\u6210\u4eba\u30fb\u672a\u6210\u5e74\u3092\u51fa\u529b\u3059\u308b\u4f8b\u3002 session.query( Person.id, Person.n\u2026","author_url":"https://blog.hatena.ne.jp/chyka/","height":"190","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fchyka.hatenablog.jp%2Fentry%2F2016%2F03%2F14%2F002436\" title=\"SQLAlchemy\u3067&quot;case&quot; - Sing it out\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","categories":["Python","SQLAlchemy"],"version":"1.0","provider_url":"https://hatena.blog","blog_title":"Sing it out","author_name":"chyka","url":"https://chyka.hatenablog.jp/entry/2016/03/14/002436"}