I use MySQL database
Two tables:
Table 1 articles

  Field: article nb  article description supplier     cell
              100    nails               company 1     no
              200    screws              company 2     yes

Table 1 stock

Field: article nb.  barcode nb. barcodedescription instock
        100        10011          nails 2 inch       5000
        100        10012          nails 5 inch       0
        200        20012          screw 2 inch       7500
        200        20013          screw 3 inch       0       
        200        20014          screw 5 inch       8000                  

I would compare these two tables ( subquery or inner join) and only show articles that are instock and cell is YES

So result is

  field: article nb.  supplier  cell barcode nb. barcodedescription  instock
          200          supplier2  yes    20012        screw 2 inch      7500
          200          supplier2  yes    20014        screw 5 inch      8000

Who can help me with this if you please

<

Recommended Answers

All 3 Replies

Its a easy task. U better learn some joins for database. I am writing a pesudo query for you , use the syntax and build one for you.

select the required fileds from table t1, table t2 where t1.articlenb = t2.article and t1.cell = 'yes' and t2.instock > 0

here is query of mssql , i dont know about mysql , it may not work in mysql , but it will give you an idea to solve your prob.

select s.articlenb , a.supplier ,a.cell, s.barcodenb s.barcodedescription s.instock
from stock s
inner join articles a on a.articlenb = s.articalnb
where a.cell = 'Yes'
'if cell field is varchar or text then use 'Yes' and if cell field is boolean type or bit then use 1 and 0

Regards

select s.articlenb , a.supplier ,a.cell, s.barcodenb s.barcodedescription s.instockfrom stock sinner join articles a on a.articlenb = s.articalnbwhere a.cell = 'Yes'

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.