zhwomen_help_demand 查出 id,name,sex,tel 字段条件是state=1 order by id desc,并统计id字段在zhwomen_help_application中出现了多少次
zhwomen_help_demand id字段 关联
zhwomen_help_application helpid字段
例句:
select id,name,sex,tel from zhwomen_help_demand where state=1 order by id desc
select count(*) from zhwomen_help_application where helpid=id
一个对我来说比较难的SQL如何写
答案:2 悬赏:20 手机版
解决时间 2021-02-23 19:05
- 提问者网友:無理詩人
- 2021-02-23 04:17
最佳答案
- 五星知识达人网友:爱难随人意
- 2021-02-23 05:06
select a.id,a.name,a.sex,a.tel,count(a.id) from zhwomen_help_demand as a inner jion zhwomen_help_demand as b on a.id=b.helpid
where a.state=1 group by a.id,a.name,a.sex,a.tel
order by a.id desc
where a.state=1 group by a.id,a.name,a.sex,a.tel
order by a.id desc
全部回答
- 1楼网友:从此江山别
- 2021-02-23 05:30
select a.id,a.name,a.sex,a.tel,b.cou from zhwomen_help_demand a,
(select id, count(*) as cou from zhwomen_help_application group by id) b
where a.state=1
and a.id=b.id
order by a.id desc
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯