Hello,

SELECT DISTINCT F1, F2 in SQL means that you will have distinct (F1, F2)
tuples / records. This does not imply that you will have distinct values
for F1. You have several options, depending on what the true intent of your
query is:

1. Use GROUP BY instead:

   Map<String,String> resultMap = .select(Tables.T1.F1,max(Tables.T1.F2))
.from(Tables.T1)
                        .groupBy(Tables.T1.F1)
.fetch()
.intoMap(Tables.T1.F1, max(Tables.T1.F2));

2. Collect values into a List:

   Map<String,List<String>> resultMap = .selectDistinct(Tables.T1.F1,
Tables.T1.F2)
.from(Tables.T1)
.fetch()
.intoGroups(Tables.T1.F1, Tables.T1.F2);

Hope this helps,
Lukas

2014-09-13 23:57 GMT+02:00 <[email protected]>:

> I have a non-unique field that I'm pulling from MySQL 5.6 (testing with
> 5.7 as well)
>
> Map<String,String> resultMap = .selectDistinct(Tables.T1.F1,Tables.T1.F2)
> .from(Tables.T1)
> .fetch()
> .intoMap(Tables.T1.F1, Tables.T1.F2);
>
> drops a run-exception that the F1 is not unique...
>
> The result of the DISTINCT are unique.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to