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


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')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.