文章详情页
MYSQL 运算的问题
浏览:180日期:2022-06-18 17:02:48
问题描述
我的某个MYSQL数据表A中有两个字段分别是 type 和 param。我需要当type的值为1的时候从表B中取一个值,当type的值为2的时候从表C中取一个值。
要用一条语句来实现要怎么写(其实主要是在SELECT和FROM之间做一个type值的判断)
问题解答
回答1:方法一:
select case when a.type=1 then b.col else c.col endfrom a,b,c
方法二:
select a.type, b.colfrom a, bwhere a.type=1unionselect a.type, c.colfrom a, cwhere a.type=2回答2:
select case when type = 1 then a.*** else b.*** end as *** from a,b,c ...
相关文章:
1. docker api 开发的端口怎么获取?2. debian - docker依赖的aufs-tools源码哪里可以找到啊?3. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””4. 我何时应该在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)5. golang - 用IDE看docker源码时的小问题6. 关于docker下的nginx压力测试7. nignx - docker内nginx 80端口被占用8. 对html实现监测 发现不对9. python - 使用pandas的resample报错10. mac连接阿里云docker集群,已经卡了2天了,求问?
排行榜

网公网安备