select a.*, b.uname from table1 a, table2 b
where a.uid = b.uid and a.orderid in 
(select orderid from table1 group by orderid having count(*)=1)

解决方案 »

  1.   

    SELECT 表1.orderid, 表1.isbn, 表1.uid, 表1.number, 表2.uname, 表2.upass
    FROM 表1 LEFT JOIN 表2 ON 表1.uid = 表2.uid;
      

  2.   

    select distinct a.orderid,a.isbn,i.uid,a.number,a.price,b.uname
    from table1 a left join  table2 b
    on a.uid = b.uid
      

  3.   

    Select distinct table1.orderid from table1
    inner jion table2 on table1.orderid=table2.uid
    where table2.uname in(select uname from table2)
      

  4.   

    "从表一中提出orderid唯一的所有记录"是只出现一次的orderid吧。select A.orderid,A.isbn,A.uid,A.number,A.price,B.uname
    from 
    (select * from table1 group by orderid having count(*)=1) A 
    left join  
    table2 B
    on A.uid = B.uid
      

  5.   

    结果应该是这样的
    20030617144730      2005356755      7              1         33.2000              
    20030617165312      2002061415      7              1         25.0000          
        
    如果orderid重复的只显示其中的一条!
      

  6.   

    alter table t1 add newfield int identity(1,1)
    select t1.*,t2.name from t1,t2 where t1.uid=t2.id 
    and t1.newfield in (select min(newfield) from t1 group by uname )alter table t1 drop column newfield
      

  7.   

    select distinct a.orderid,a.isbn,i.uid,a.number,a.price,b.uname
    from table1 a left join  table2 b
    on a.uid = b.uid
      

  8.   


    select table1.* ,table2.uname from table1,table2 where table1.uid=table2.uid and orderid in( select orderid from table group by orderid having count(orderid)=1)
      

  9.   

    这个高级。来这里捣乱一下select a.*,b.uname from table1 a,table2 b
    where table1.uid=table2.uid 
    and a.isbn=(select isbn from table1 where orderid=a.orderid)
    and a.number=(select number from table1 where orderid=a.orderid and isbn=a.isbn)
    and a.price=(select price from table1 where orderid=a.orderid and isbn=a.isbn and number=a.number)错了不管!哈,哈哈,哈哈哈......
      

  10.   

    select a.*,b.uname from table1 a,table2 b
    where table1.uid=table2.uid 
    and a.isbn=(select max(isbn) from table1 where orderid=a.orderid)
    and a.number=(select max(number) from table1 where orderid=a.orderid and isbn=a.isbn)
    and a.price=(select max(price) from table1 where orderid=a.orderid and isbn=a.isbn and number=a.number)错了不管!哈,哈哈,哈哈哈......