SQLTeam.com | Weblogs | Forums

Simple newby next level query

Hello all and thank you for accepting me to the forum.

I have a what is probably a very simple query but one I don't know how to construct, so far I have been working on simple one row queries. A database I am working on has the following rows;

ProductID ProdType Description
1 0 Generator
1 3 Brush Kit
1 6 Bearing Kit

This is simplified and not all ProductIDs will have associated support items. The two queries I would like to construct is one where a ProductID has no associated support items and the second one where a particular ProductID has a duplicated ProductType.

I'm guessing this is just a mindset block in my newby understanding and simple to overcome, thank you in advance for your anticipated help.

Sergio

Welcome Sergio

Could you show what things you have tried?

Hi,

Very simple queries as I am really new to sql and wanting to learn so,

Select * from ProductTable
Where ProductID = '1'
Where ProductID Like '%generator%'

etc. as I said I am at the very beginnings of learning but can understand a Join where items are in two tables. I guess this is a case of Distinct or not Distinct which I'm struggling with a bit.

As I said there would be instances where I would want to see a unique ProductID (has no supporting products like spare parts) and other times I would be wanting to see all Descriptions where for example I had Bearing kits, bit like a Join within a single table if that makes any sense?

Sergio

hi

hope this helps :slight_smile:

you can use
OR clause
or
Union ALL

select where clause1 OR clause2

select clause1
union all 
select clause2