Reputation: 33
Trying to make query for 4 hours. For example i have such data:
did title number_link ltitle
35 about.html 1 NULL <- this
35 about.html 2 NULL <- this
36 about.html 1 NULL
35 contact.php 1 NULL <- this
35 contact.php 3 NULL <- this
36 contact.php 1 NULL
How to chose distinct title and distinct number_link ? I have marked with "<-" what i want to get from query. Thanks in advance.
Upvotes: 0
Views: 87
Reputation: 263693
This query will allows you to get all the column with in the row not just title
and number_link
.
SELECT a.*
FROM tableName a
INNER JOIN
(
SELECT title, number_link, MIN(did) did
FROM tableName
GROUP BY title, number_link
) b ON a.title = b.title AND
a.number_link = b.number_link AND
a.did = b.did
Upvotes: 1
Reputation: 190
SELECT title,number_link FROM table GROUP BY title, number_link;
Upvotes: 0