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

Link to comment
https://forums.phpfreaks.com/topic/297490-help-with-a-select-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.