0

dear all..i have this data inside DB:

line     model        serial      
fa01     kd-g335ud   105x0001     
fa01     kd-g335ud   105x0002     
fa01     kd-g335ud   105x0003 //up to 20pcs or regardless of the number of goods in the db
fa02     kd-r311ed   105x0001
fa02     kd-r311ed   105x0002 //up to 20pcs or regardless of the number of goods in the db

i want if every "model" have reached 20 pcs or regardless of the number of goods in the db, the data will appear at quantity page like:

line     model      qty
fa01    kd-g335ud    20
fa02    kd-r311ed    20

please help, thanks before :-)

2 Answers 2

2

SELECT line, model, count(serial) as qty FROM table_name GROUP BY line, model

Not 100% sure on my query, but that is along the lines of what you want. Hopefully that query is correct!

Sign up to request clarification or add additional context in comments.

2 Comments

after the result appear, how to ditribute the result to the quantity page?
Through using the php mysql functions? For a tutorial on how to do this: siteground.com/tutorials/php-mysql/display_table_data.htm (not sure on the quality of that tutorial).
0

you are not explaining it well. you said "i want if every "model" have reached 20 pcs or regardless of the number of goods..." what about the line. regardless of the line or in regards :)? If you want every model regardless of the line and serial then:

SELECT model, count(model) AS QUANITY FROM [table name] GROUP BY model;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.