I have below tables:-


Ownerid ownerFirstname Lastname
1 Abc A
2 Xyz X
3 Pqr P


Listid Listname
1 List1
2 List2


Detailid Listid Ownerid
1 1 1
2 1 2
3 2 1
4 3 1


TagId Tagname
1 tag1
2 tag2


Detailid Tagid Ownerid
1 1 1
2 1 2
3 2 1
4 3 1

The result i want as, All table joins and all column and no duplicate row from tblOwnerdetails with where clause

What I've tried so far:

select o.* from tblOwnerDetails o
inner join tblListDetail ld
on ld.OwnerId = o.OwnerId
inner join tblListMaster lm
on lm.ListId = ld.ListId
inner join tblListMaster
on ld.ListId = lm.ListId
left join tblTagDetail td
on td.OwnerId = o.OwnerId
inner join tblTagMaster tm
on tm.TagId= td.TagId
where Tagname = 'Tag1' || Listname = 'List1'

where clause may be included or may not be included.

  • 2
  • Please put all of your tables and their data into a fiddle (dbfiddle.uk) and also give us what you wish your final resultset to be! OK, at least you've tried something, but I can't tell from it what it is, exactly, you require! Please put all of those details back into the question also (edit link under the question) - help us to help you!
    – Vérace
    Sep 14 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.