I would like to join two tables but to specify that the result should have unique values on one of the columns.
http://sqlfiddle.com/#!2/70ded/4
Instead of
URLID DOMAINID
13 5
9 3
10 3
11 4
12 4
6 2
7 2
8 2
1 1
2 1
3 1
4 1
5 1
I would like to get:
URLID DOMAINID
13 5
9 3
11 4
6 2
1 1
Is it possible doing it and by that creating a faster query?
Your query will not be faster, because you have to remove the duplicates. Here is a MySQL way:
This uses a MySQL mis(feature) called hidden columns. In most databases, you would use: