首先对近来看这个帖子的各位我说声谢谢了,因为在csdn里面对没分的帖子大家一般都不会看的,好了说正题。。求一个这样的sql 语句
从session 里面区一个值 让a,b,c,d表里面的值得都等于这个
然后count()a,b,c,d表里面的信息, 在count(renzheng)a,b,c,d表里面的信息
也就是count()两次
从session 里面区一个值 让a,b,c,d表里面的值得都等于这个
然后count()a,b,c,d表里面的信息, 在count(renzheng)a,b,c,d表里面的信息
也就是count()两次
count(renzheng)又是什么意思 ???
从session 里面区一个值 让a,b,c,d表里面的值得都等于这个
这个是在程序里面写的吧..
是不是有个字段是标识批准发布的啊?count(*) --一共有多少条数据
sum(case when renzheng='批准' then 1 else 0 end) --批准的有多少条
看看 一共发多少条,和批准了多少条
select count(*) from tb where column='批准发布'
select count(*) from b where user_name = 'xuemiao'select count(*) from b where supply_authentication = 'y' and user_name = 'xuemiao'
select count(*) from c where user_name = 'xuemiao'select count(*) from c where supply_authentication = 'y' and user_name = 'xuemiao'
select count(*) from d where user_name = 'xuemiao'select count(*) from d where supply_authentication = 'y' and user_name = 'xuemiao'
意思就是 当用户登陆以后 查看他在a b c d 表里面的信息,
看看 一共发多少条,和批准了多少条
--------------------------------------------
还是没说明白.
a b c d是4个表吧?它们的关联关系是什么?
1个用户的发布信息存在4个表里吗?
批准了多少条是什么意思?用什么字段来表示是否批准?
select count(*) as total,sum(case when supply_authentication='y' then 1 else 0 end) as supply_authentication from a where user_name = 'xuemiao'
union all
select count(*) as total,sum(case when supply_authentication='y' then 1 else 0 end) as supply_authentication from b where user_name = 'xuemiao'
union all
select count(*) as total,sum(case when supply_authentication='y' then 1 else 0 end) as supply_authentication from c where user_name = 'xuemiao'
union all
select count(*) as total,sum(case when supply_authentication='y' then 1 else 0 end) as supply_authentication from d where user_name = 'xuemiao'
)t
看看 一共发多少条,和批准了多少条
select count(*) from (
select user_name,supply_authentication from a
union all
select user_name,supply_authentication from b
union all
select user_name,supply_authentication from c
union all
select user_name,supply_authentication from d)a
where user_name = 'xuemiao' 和批准了多少条
select count(*) from (
select user_name,supply_authentication from a
union all
select user_name,supply_authentication from b
union all
select user_name,supply_authentication from c
union all
select user_name,supply_authentication from d)a
where user_name = 'xuemiao' and supply_authentication = 'y'
是吗
程序里的东西就不要说出来了~~害我丢人...