表a caiid 名称
1 青菜
2 土豆
表b caijia
id 菜名 价格 数量 日期
1 1 2 3 2009-4-1
2 2 3 1 2009-4-11现在想查询出这样一张表菜名 2009-4-1 2009-4-2 ... 2009-4-30
青菜 6 x x
土豆 x x x
想来想去,想出一个超笨办法
select id,名称,(select 价格 from caijia where cai.id=caijia.菜名 and 日期=#2009-04-11#
) as day1,(select 价格*数量 from caijia where cai.id=caijia.菜名 and 日期=#2009-04-12#
)as day2 from cai用程序语言循环写出每月每天的select然后拼接估计这个办法也是笨到家了鄙视自己一下,
有高手愿意批判一二吗
1 青菜
2 土豆
表b caijia
id 菜名 价格 数量 日期
1 1 2 3 2009-4-1
2 2 3 1 2009-4-11现在想查询出这样一张表菜名 2009-4-1 2009-4-2 ... 2009-4-30
青菜 6 x x
土豆 x x x
想来想去,想出一个超笨办法
select id,名称,(select 价格 from caijia where cai.id=caijia.菜名 and 日期=#2009-04-11#
) as day1,(select 价格*数量 from caijia where cai.id=caijia.菜名 and 日期=#2009-04-12#
)as day2 from cai用程序语言循环写出每月每天的select然后拼接估计这个办法也是笨到家了鄙视自己一下,
有高手愿意批判一二吗
用SP OR 程序 循环,字符串累加得到SQL语句,再执行