Jump to content

Help with a select query


yandoos

Recommended Posts

Hello i was really hoping for some help with a select query. Before I explain the issue here is the background.

 

I have 3 tables - products, clients, distributions

 

product table

pid

productname

description

price

 

client table

cid

name

age

 

distribution table

pdid

pid*

cid*

status

date

 

I am in the process of building the add distribution form and want to use a select query that will dynamically show the options in a dropdown and  join the 3 tables.

SELECT name, client.cid FROM distribution join product ON distribution.pid = product.pid
                                  join client ON distribution.cid = client.cid

echo '<option value="'.$build['cid'].'">'.$build['name'].'</option>';

Here is the problem... I want ONLY to select the cid and name from the distribution table that has less than 10 records. This is because a client can have only a maximum of 10 distribution records. So I only want these clients to appear as options in the dropdown as opposed to all the clients names and cids. 

 

I really don't know how to achieve this so any help would be ace.

 

Thank you

Edited by yandoos
Link to comment
Share on other sites

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.