php - Need help with a MySQL statement -


i have table of products looks so:

|    id   |    description   |   price    | |    1    |  dinglehopper    |    2.99    | |    2    |  flux capacitor  |   48.99    | |    3    |  thing1          |   48.99    | 

and on...

then have orderlineitem table which, can guess, links each item in order product:

|    id   |    productid     |   orderid  | |    43   |  1               |    12      | |    44   |  2               |    12      | |    52   |  3               |    15      | 

so, can see, order #12 contains dinglehopper , flux capacitor. how can information in single query? want products associated given orderid in orderlineitem table.

may by

select p.description,p.id,o.irderid       `orderlineitem` o, `product` p       p.id = o.productid; 

or

select p.description,p.id,o.irderid  `orderlineitem` o join  `product` p  on p.id = o.productid; 

Comments