how can i select suppliers based on oldest date?

I am working on a ecommerce project and want to select suppliers based on oldest date…Here is myDB design
Product
[php]id(PK) name price added_date(DATE)
1 Samsung Note 180000 2016-09-30
2 Nokia Lumia 510 215000 2016-09-29[/php]
Supplier
[php]id(PK) name registered_date(timestamp) stock
1 Easyshop 2016-09-30 12:50:12 10
2 T-mobile 2016-09-30 12:55:36 10[/php]
product_supplier
[php]itemid(pk) supplierid(pk)
1 2
1 1[/php]
As you can see the item 1 as 2 suppliers. So, What i want to do: is to select items based on first added suppliers (like in FIFO method- first in - first out)
How can do such join query with timestamp as condition?

You join is dependent on the linking table, so you would do a where clause on the lowest supplier id, or and order by registered date asc.

Sponsor our Newsletter | Privacy Policy | Terms of Service