ordered(id productid userid) product(id productid pp xh xl) brands(id pp name) user(userid username)用一条SQL语句查出ordered中所有产品的名称,品牌,用户名.(不是编号)谢谢~

解决方案 »

  1.   

    select 名称,品牌,用户名 from ordered,product,brands,user where ordered.productid=product. productid and ordered.userid=user.userid and product.pp=brands.pp;
      

  2.   

    ordered(id productid userid) 
    product(id productid pp xh xl) 
    brands(id pp name) 
    user(userid username)用一条SQL语句查出ordered中所有产品的名称,品牌,用户名.(不是编号) select p.xl -- 产品名称?
         , b.name -- 品牌? 
         , u.username
    from ordered o
    join product p on o.productid=p.productid
    join brands b on p.id=b.id and p.pp=b.pp -- Join On(id, pp)?
    join user u on o.userid=u.userid