---
title: "使用sql语句获取一对多中的第一条记录"
author: "ljf_home"
date: "2015-04-16T19:13:15Z"
tags: []
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2015-04-16T19:13:15Z"
id: 2203094
url: "https://rsy.iteye.com/blog/2203094"
---

select * from 表1,表2 where 表1.关联字段=表2.关联字段 and 表2.主键 in(select min(主键) from 表2 group by 关联)