如何在PostgreSql数据中SELECT的时候A字段如果内容空就返回B字段的内容?

0
PostgreSQL 数据库 39443 次浏览

   content表有一个body字段和clean_body字段,单独获取body很容易用,select body from content就可以了,最近业务需要扩展了一个clean_body字段,用来存放body清洗后的数据。现在业务逻辑就是在clean_body中内容为空时,自动到body中去获取数据。

   如果直接将两个字段的内容都读出(select body,clean_body from content)然后在代码中自己判断也是可以的,这样做总觉得怪怪的,如果在数据库一层就可以做到的话是最完美的!

请尽量让自己的答案能够对别人有帮助

40个答案

默认排序 按投票排序
0

Well resolving such issues is important because of many reasons. Thanks! stlouistreeco.com

0

Thank you for your post. I have read through some similar topics! However, your article gave me a very special impression, unlike other articles. I hope you continue to have valuable posts like this or more to share with everyone! tetris

0

Very Informative, since PostgreSQL is mostly used on Linux systems right? correct me if im wrong. Bathroom Remodeling Brooklyn NY

0

Keep the outside of your entire house looking spotless with our Tallahassee control washing administrations! Here is the conclusive list of Tallahassee's power washing administrations as appraised by the Tallahassee, FL pros.

0

Lubbock's Top Power Washing Business. 

0

Gladly advertising the most elevated quality outside pressure washing, control clearing, and commercial cleaning administrations in Lubbock & encompassing ranges. Call Right Now. 

0

really good and very explainable series of postgresql. small excavator service

0

I would appreciate it if somebody can tell me where to dowload it, thanks. abrasive blasting

0

PG Slot  true wallet

0

slotxo true wallet

0
0
0
0
0
0
0
0
1 2