i have two similar tables with the same fields. One is named "input" and the other "product" Both have the same fields:
- id
- name
- qty
- unit
- price
- pic(fk - both reference the same picture table).
My first question is: How can I write a query to effectively return every item's details?
I use JSON to export this data
$json_data.='"rec'.$i.'":{"id":"'.$id.'", "name":"'.$name.'", "price":"'.$price.'", "qty":"'.$qty.'", "units":"'.$unit.'", "pic":"'.$pic.'"},';`.
My second question is: How can i effectively reference all the fields from both tables?
NB: I don't want to put the two categories in the same table, say, item
, with an additional field of category
.
Just to rectify this: the join condition is (input.pic=pic.id and product.pic=pic.id)