Help with query from 2 tables (php/mysql)

table one (production)

SELECT id, name, image FROM production WHERE catname = '".$show_cat."' ORDER BY RAND() DESC

table two (prices) (Can be more when one price of product id)

SELECT product_price, product_weight FROM prices WHERE product_id = '".$id."'

I need to do

.-------------------------------------------------------
| ID |  PRODUCT  |  PRICE | AND OTHER INFORMATION ....
 -------------------------------------------------------
| 1  | Milk      |  1000  |
 -------------------------------------------------------
| 2  | Beer      |  1000  |
|    |           |  1500  |
|    |           |  2500  |
 -------------------------------------------------------

thanks (sorry for my english)

sorry i thing i need php more help when mysql

SELECT production.id
     , production.name
     , production.image
     , price_product.product_price AS price
     , price_product.product_weight AS weight
  FROM production
LEFT OUTER
  JOIN prices AS price_product
    ON price_product.product_id = production.id
ORDER 
    BY production.id

it’s ok ? (if yes need php help) :frowning:

what happened when you tested it? ™

hint: yes it is

:slight_smile:

@Smolf3d; Don’t forget that any user-submitted data must be sanitized before being allowed anywhere near to the database. The best way is by using prepared statements

After some tests i found the problem, this is not mysql … php :frowning:

Now work perfect , but thanks for replies :slight_smile: And SpacePhoenix yep i know )))