Welcome Guest, Not a member yet? Register   Sign In
join problem..?
#1

[eluser]amira_fcis[/eluser]
hi all,
i have 2 tables the 1st has names
the second has the values

i made join between 2 tables to get names and values
and i got result something like that

ahmed 1
ahmed 2
ahmed 3

and i want the result to be

ahmed
1
2
3

how can i get this result???
#2

[eluser]sl3dg3hamm3r[/eluser]
You want fields from different columns in one column? This doesn't make sense... use php to achieve this.
#3

[eluser]amira_fcis[/eluser]
thanks sl3dg3hamm3r for ur concern
no i doesn't mean that.i mean


NAME Value

ahmed 1
2
3
#4

[eluser]sl3dg3hamm3r[/eluser]
That's the nature of joins: You might end up with redundant data like in 'Name', in your case. A result from a db-query is always a flat table (except deletes, updates) and not any kind of a tree consisting of nodes and leaves.
#5

[eluser]amira_fcis[/eluser]
you mean that i never echo this result with any possible way??
#6

[eluser]sl3dg3hamm3r[/eluser]
Err sure it is, that's why I said 'Use php' to achieve what you want. You will need to iterate over your result-set. If 'Name' was echoed and didn't change since last iteration, don't echo it anymore.
#7

[eluser]amira_fcis[/eluser]
Any suggestions to do that...?coz i did my best but i couldn't reach my target result

thanks in advance
#8

[eluser]sl3dg3hamm3r[/eluser]
[quote author="amira_fcis" date="1258553511"]coz i did my best but i couldn't reach my target result[/quote]

And what did you do until now?

Code:
$tmpName = "";
foreach ($query->result() as $row)
{
  if ($tmpName != $row->Name) {
    echo $row->Name . " " . $row->Value;
    $tmpName = $row->Name;
  } else
    echo $row->Value;
}
This is some untested code. It implies that you have 'Name' and 'Value' in your result-set.




Theme © iAndrew 2016 - Forum software by © MyBB