If the goal is to return the most recent review title for "mobile" and for "pc", I'd do something like this:
SELECT q.username
, MAX(q.pc_date) AS pc_date
, MAX(p.title) AS pc_title
, MAX(q.mobile_date) AS mobile_date
, MAX(r.title) AS mobile_title
FROM ( SELECT t.username
, MAX(IF(t.via_mobile='false',t.review_date,NULL) AS pc_date
, MAX(IF(t.via_mobile='true',t.review_date,NULL) AS mobile_date
FROM tripadvisor t
WHERE t.username <> ''
AND t.via_mobile IN ('true','false')
GROUP
BY t.username
) q
LEFT
JOIN tripadvisor p
ON p.username = q.username
AND p.review_date = q.pc_date
AND p.via_mobile = 'false'
LEFT
JOIN tripadvisor r
ON r.username = q.username
AND r.review_date = q.mobile_date
AND r.via_mobile = 'true'
GROUP
BY q.username
If the user has only "mobile" reviews and no "pc" reviews, this query will return a row, but with NULL values for the "pc" columns. Similarly, the query will return NULL values for the "mobile" columns for a user that has only "pc" reviews.
The query could easily be changed to only returns rows for users that have both "mobile" and "pc" reviews, to be closer to the original using the INNER JOIN.
If the goal is simpler, just to return just the most recent review...
SELECT r.username
, r.review_date
, MAX(r.title) AS title
, MAX(r.via_mobile) AS via_mobile
FROM ( SELECT t.username
, MAX(t.review_date) AS max_review_date
FROM tripadvisor t
WHERE t.username <> ''
AND t.via_mobile IN ('true','false')
GROUP
BY t.username
) q
JOIN tripadvisor r
ON r.username = q.username
AND r.review_date = q.max_review_date
AND r.via_mobile IN ('true','false')
GROUP
BY r.username
, r.review_date
The results of this query are somewhat indeterminate when a username
has multiple rows with identical (most recent) review_date
. This guarantees a single row will be returned, but the title
and via_mobile
may not be from the same row.