The problem I encountered was: to get the first picture in the Project_id field, the Pic_url field. But how do I get the project_id is the field of the 27 Pic_url, and so on to get to the first picture of 28,29,30?
Two details:
The appearance of the picture is not always the first;
Get three pictures of three project_id, no longer need pictures in the back.
 
Thank
 
 
Reply content:
 
The problem I encountered was: to get the first picture in the Project_id field, the Pic_url field. But how do I get the project_id is the field of the 27 Pic_url, and so on to get to the first picture of 28,29,30?
Two details:
The appearance of the picture is not always the first;
Get three pictures of three project_id, no longer need pictures in the back.
 
Thank
 
 
MySQL database allows group to select non-group fields
 
 
  
  But it's not the 1th one, not very clear.
 
 
 
 
select  project_id, pic_urlfrom    picswhere   pic_url is not nullgroup    by  project_id;
 
But since there's a self-increment ID,
 
You can min(id) find the minimum ID that meets the criteria, then connect the query to get the data you need.
 
select  b.*from    (        select  project_id, min(id) as id        from    pics        where   pic_url is not null        group            by  project_id        ) a    left join pics b on a.id = b.id;