乐趣区

关于mysql:SQL语句记录

1. sql 查找一列中呈现次数大于 8 的记录

select 
  `POID` 
from 
  `orderDetail` 
group by 
  `POID` 
having count(*) >8;

2. SQL 查找汇合中的记录

select 
  `OID`
from 
  `orderHead`
where 
  `OID` in (
    select 
      `POID`
    from
      `orderDetail`
    group by 
      `POID` 
    having count(*) > 8
);
退出移动版