Jump to content

Recommended Posts

Hey all,

 

Here is a brief(ish) explanation of my problem. I've omitted all fields that aren't relevant to the query. I have three tables.

 

1. manufacturer which contains an fields called manufacturerID (type int) and manufacturerName (type varchar).

 

2. productType which contains fields called productTypeID (type int) and productDescription (type varchar)

 

3. product which contains fields productID (type int), productName (type varchar), manufacturer (type int) and productType (type int)

 

 

Now for example, a kind of product type is "Monitor" and that has a productTypeID of 2.

 

I want to list all manufactrurerName where one or more products made by that manufacturer are monitors i.e. all manufacturers who made monitors.

 

I can do this using more than one query but I suspect there is a way of doing this in a single query. 

 

Can anyone tell me how this is done please?

 

Thanks in advance! I've been trying to get my head around this for several hours!

 

 

Chris.

Link to comment
https://forums.phpfreaks.com/topic/278083-cant-get-my-head-around-this/
Share on other sites

Thanks. Before I read your post I was thinking along the lines of:

SELECT * FROM manufacturer m WHERE m.manufacturer IN (SELECT p.manufacturer FROM product p WHERE p.productType=2);

But I don't think that's a join - and its close to midnight here so my brain is starting to melt.

 

I'll read up on joins. I did lots of SQL training with Oracle but that was 22 years ago and I haven't used it at all since!

 

Thanks for your response!

Edited by ChrisCwmbran
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.