0

So here's the problem I can't work around today.

I want to grab some details from a database. I'm not sure how to explain this. But here goes.

Database Example:

TITLE | DESCRIPTION | IDENTIFIER

1 | Description | abc
2 | Description | abc
3 | Description | def

I want to select the first row with the identifier "abc" and then I want to skip the next row which has the same field "abc".

I'm trying to use this in a SELECT mysql_query in PHP

4

5 回答 5

1

要获得完整的行,您可以执行

select * from your_table
where title in 
(
  select min(title)
  from your_table
  group by identifier
)
于 2013-08-22T16:16:29.683 回答
1

这个?

SELECT DISTINCT(identifier), title, description FROM tablename

在这种情况下,它还将返回带有“def”的行。

于 2013-08-22T16:27:20.197 回答
0

看起来整数字段被称为“标题”。这应该抓住最低的标题 # 但根据您的要求删除重复项。

select min(title) as firstTitle, description, identifier
  from table_name
  where identifier in (select distinct identifier from table_name)
  group by description, identifier.
于 2013-08-22T16:22:51.830 回答
0
select min(TITLE) as TITLE, DESCRIPTION , IDENTIFIER 
From your_table
Group by DESCRIPTION , IDENTIFIER 
于 2013-08-22T16:23:00.947 回答
0
select id, description, identifier 
from table group by identifier order by id asc;
于 2013-08-22T16:35:11.540 回答