I have a table that keeps something like below:
Table A:
1 admin ABC
2 admin DOG
3 admin CAT
1 id1 FISH
1 id2 BIRD
Table B:
admin DETAILS1
id1 DETAILS2
id2 DETAILS3
I want to select from the 2 tables but only select with the condition that it only takes the row in Table A whereby the first column is the maximum. meaning it should only take:
3 admin CAT
1 id1 FISH
1 id2 BIRD
and join with table B resulting in
3 admin CAT DETAILS1
1 id1 FISH DETAILS2
1 id2 BIRD DETAILS3
SELECT DISTINCT staff.rid, staff.name, staff_firma.firma, MAX(staff_firma.rid) FROM staff, staff_firma WHERE staff.uid=staff_firma.uid GROUP BY uid
I used that code, number of records that come out is correct but for those with userid 'admin'.
it doesn't come out
3 admin CAT DETAILS1
instead it comes out eg:
3 admin DOG DETAILS1