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)
where a.uid = b.uid and a.orderid in
(select orderid from table1 group by orderid having count(*)=1)
FROM 表1 LEFT JOIN 表2 ON 表1.uid = 表2.uid;
from table1 a left join table2 b
on a.uid = b.uid
inner jion table2 on table1.orderid=table2.uid
where table2.uname in(select uname from table2)
from
(select * from table1 group by orderid having count(*)=1) A
left join
table2 B
on A.uid = B.uid
20030617144730 2005356755 7 1 33.2000
20030617165312 2002061415 7 1 25.0000
如果orderid重复的只显示其中的一条!
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
from table1 a left join table2 b
on a.uid = b.uid
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)
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)错了不管!哈,哈哈,哈哈哈......
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)错了不管!哈,哈哈,哈哈哈......