Hi,
I have 3 tables that I need to get data from anp output all together. Well, in fact i need to get it into one table, but if I could output it first taht would be great.
The first table is pretty starihgt forward:
_migra_PROD
ID int(11)
CODE
NAME
IMAGE
DESC
_migra_CUST1
group int(11)
ID int(11)
value
_migra_CUST2
cust2_group int(11)
cust2_ID int(11)
cust2_value
I am trying to pull values together like that:
$prod = $db->get_results("SELECT * FROM _migra_PROD
LEFT JOIN _migra_CUST1 ON ( _migra_CUST1.ID = _migra_PROD.ID )
LEFT JOIN _migra_CUST2 ON ( _migra_CUST2.cust2_ID = _migra_PROD.ID )
");
Now, the pronlem is that the first table's values are on per line, the other two tables have several lines for each ID. For example it may look like that:
group ID value
42 25 value1a
80 25 value1b
79 25 value1c
80 22 value2a
79 22 value2b
Besides getting all sorts of MySQL errors, which I probably could debug, when I join table 2 or 3 to the the first one my output becomes repeated multiple time. I assume it is because of how many times each ID appearing in those tables.
After a long day, I'm getting nowhere with that. Need fresh eye and better yet, fresh brains...