0

i have three table i attached db files with query result i am getting. my query is below

select tts.transaction_id,tts.service_type,tt.theme_name from transactions tts
inner join users tu on tu.user_id=tts.user_id
inner join themes tt
where tts.user_id =  71 
and tts.service_type in ('purchased','startup_service')
group by tts.theme_transaction_id;

i am not getting write theme name user_id 71 purchase.
when user purchase services there is no theme_id available so it's 0 but if theme purchase then theme id will be there.
hope any one can expain write approch or query. thanks

65f5040b1fb7ea40ad2946bbc77ef79a
052e76b6b780451d45ee1117d7c87732b92c799cb5ef24244dea8ba7ba65ecc444ca21f5ee3a357f4f3b7b77f66019b8

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by Taywin
0

Hmm... Is the query exactly what you used? Well, why do you need 'group by' when what you are trying to group is already unique in its own? Also, I prefer to use like instead of in if the condition is not dynamic (predefined). My attempt is below...

SELECT tts.theme_transaction_id, tts.service_type, tt.theme_name
FROM tts left join tt on tts.theme_id=tt.theme_id
WHERE tts.user_id=71 and
      (tts.service_type like 'purchased' or
      tts.service_type like 'startup_service')

Edited by Taywin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.