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


3 Years
Discussion Span
Last Post by Taywin

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.