4 Replies - 575 Views - Last Post: 16 February 2017 - 11:31 PM

#1 little_prince41  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 163
  • Joined: 10-August 07

How to select muti table on php?

Posted 14 February 2017 - 09:15 AM

Hello , I want to calculate model stock from material stock by refer usage , There are 3 table on Mysql=> component part for model, part stock, model stock as below.

Table 1 * usage for model X

Quote

----------------------------
Partno. | usage | model
------------------------------
A | 1 | X
B | 2 | X
-----------------------------


Table 2*stock

Quote

----------------------------
Partno. | stock qty
----------------------------
A | 10
B | 20
---------------------------


Table 3* model

Quote

----------------------------
Model | stock qty
----------------------------
X | 10** what i need to calculate
Y | 20
---------------------------

As the table above, I need to show (calculate) quantity of model stock from table1 and table 2
How to make the code for mysql, pleas could you help me.

This post has been edited by little_prince41: 14 February 2017 - 09:20 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How to select muti table on php?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13389
  • View blog
  • Posts: 53,429
  • Joined: 12-June 08

Re: How to select muti table on php?

Posted 14 February 2017 - 09:17 AM

What have you tried, thought about, or considered?

What is "usage"?
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: How to select muti table on php?

Posted 14 February 2017 - 09:21 AM

what is the ' quantity of model stock' exactly?
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3695
  • View blog
  • Posts: 13,355
  • Joined: 08-August 08

Re: How to select muti table on php?

Posted 14 February 2017 - 09:43 AM

My guess is that you want to do a join of table 1 and table 2 based on the part number. If that's the case, something like this should be close:
SELECT model, `stock qty` FROM `table 1` one JOIN
  `table 2` two ON `two.Partno `= `one.Partno `
WHERE model = 'X'

Was This Post Helpful? 0
  • +
  • -

#5 little_prince41  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 163
  • Joined: 10-August 07

Re: How to select muti table on php?

Posted 16 February 2017 - 11:31 PM

I want to calculate number of Model from material stock as below picture
Could you help me, please
Posted Image

SELECT * FROM 'stock_fg'
JOIN 'BOM' tbBOM ON 'stock_fg' tbFG tbBOM.Model =tbFG.Model
JOIN 'BOM' tbBOM ON 'stock_mat' tbMat tbBOM.model_id=tbMat.model_id
WHERE 'Model' is NOT NULL

This post has been edited by little_prince41: 16 February 2017 - 11:54 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1