销售表 sell
id    selldate   num     price   id_huiyuan    id_product       re
主键  出库日期   数量     单价    会员ID         产品ID      备注,字段类型text会员表 huiyuan
id     name
主键   会员名产品表 product
id   brand    title  
主键  品牌    名称      查询结果:
品牌  商品名称 出库日期     数量   单价  总金额    会员      备注
贝亲   XX奶粉  2011-06-06     4     6      24      张三    尽快发货我想查询出这样的结果 不清楚怎么拼接查询结果 

解决方案 »

  1.   

    select c.brand as 品牌,c.title as 商品名称,
    a.selldate as 出库日期,a.num as 数量,a.price as 单价,a.num*a.price as 总金额,
    b.name as 会员,a.re as 备注
    from sell a
    left join huiyuan b on a.id_huiyuan=b.id
    left join product c on a.id_product=c.id
      

  2.   

    select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,
           price as 单价,num*price as 总金额,name as 会员,re as 备注
    from sell,huiyuan,product
    where sell.id_product=product.id and sell.id_huiyuan=huiyuan.id
      

  3.   


    select 
    a.brand as 品牌, 
    a.title as 商品名称 , 
    b.num as 数量, 
    b.price as 单价, 
    (b.num * b.price) as 总金额,
    c.huiyuan as 会员,
    b.re as 备注
    from product a , sell b , huiyuan c where 
    a.id = b.id_product and c.id = b.id_huiyuan
      

  4.   


    select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,price as 单价,sum(price) as 总金额,name as 会员,re as 备注 from sell 
    inner join huiyuan a on id_huiyuan=a.id
    inner join product b on id_product=b.id
    --按这个要求来查是不能分组的,实在要分组 直接聚合分组条件就好了
      

  5.   


    select brand as 品牌,title as 商品名称,selldate as 出库日期,num as 数量,price as 单价,price*num as 总金额,name as 会员,re as 备注 from sell 
    inner join huiyuan a on id_huiyuan=a.id
    inner join product b on id_product=b.id
    --按这个要求来查是不能分组的,实在要分组 直接聚合分组条件就好了
      

  6.   


    from sell,huiyuan,product
    就相当与内连接吧