is this possible in one query?
am 14.01.2006 16:28:13 von Sjef Janssen
Hi there,
I have a table that keeps names for different language codes.
In a short example:
nameId name languageCode
31 House EN
31 Wohnung DE
32 Piece En
32 Stuck De
33 Car EN
33 PKW DE
What I would like is to have a query that returns for example:
nameId = 31
Names = House - Wohnung
Maybe I can even have a result that consists of an array with nameIds and
Names.
Or should I fire a bunch of queries after each other to have this result?
I use mysql and php 4.3.8
Tnxs!!
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: is this possible in one query?
am 14.01.2006 18:18:12 von RaJeSh VeNkAtA
u can have the query as
$query = " select * from $table where nameId = 31 " ;
$result = mysql_query ( $query ) ;
$i = 0 ;
while ( $row = mysql_fetch_array( $result , MYSQL_NUM ) )
{
$array[$i][0] = $row[0] ;
$array[$i][1] = $row[1] ;
$array[$i][2] = $row[2] ;
$i++
}
// now $array has ur required names :-)
rajesh
On Sat, 14 Jan 2006, Sjef Janssen wrote:
> Hi there,
> I have a table that keeps names for different language codes.
> In a short example:
> nameId name languageCode
> 31 House EN
> 31 Wohnung DE
> 32 Piece En
> 32 Stuck De
> 33 Car EN
> 33 PKW DE
>
> What I would like is to have a query that returns for example:
> nameId = 31
> Names = House - Wohnung
>
> Maybe I can even have a result that consists of an array with nameIds and
> Names.
> Or should I fire a bunch of queries after each other to have this result?
>
> I use mysql and php 4.3.8
>
> Tnxs!!
>
>
--
Your absence should be long enough so that someone miss you ,
But it shouldn't be so long enough that
Someone learns to live without you
So keep in touch !
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: is this possible in one query?
am 18.01.2006 11:21:52 von Christoph Kunze
Sjef Janssen schrieb:
> Hi there,
> I have a table that keeps names for different language codes.
> In a short example:
> nameId name languageCode
> 31 House EN
> 31 Wohnung DE
> 32 Piece En
> 32 Stuck De
> 33 Car EN
> 33 PKW DE
>
> What I would like is to have a query that returns for example:
> nameId = 31
> Names = House - Wohnung
>
> Maybe I can even have a result that consists of an array with nameIds and
> Names.
> Or should I fire a bunch of queries after each other to have this result?
>
> I use mysql and php 4.3.8
>
> Tnxs!!
SELECT nameId, GROUP_CONCAT(name SEPARATOR ' - ') AS names FROM table
GROUP BY nameId
I think that will do it.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php