Group_concat - query builder

YOSRA BEN SALAH

This is my SQL operation:

select `id_ifc_espaces`,GROUP_CONCAT(DISTINCT `nom_espace`) as   nom_espace ,GROUP_CONCAT(DISTINCT `fonction_espace`) as fonction_espace, GROUP_CONCAT(DISTINCT `id_ouvrage_slab_wall`) as id_ouvrage_slab_wall , GROUP_CONCAT(DISTINCT `type_limit`) as type_limit,GROUP_CONCAT(DISTINCT `type_ouvr`) as type_ouvr from `relespouv` group by`id_ifc_espaces` 

This is Query Builder that I tried:

$relations = DB::table('relespouv')
->select('id_ifc_espaces')
->group_by('id_ifc_espaces')
->where('id_mn','=',$idmn)
->get(array(DB::raw('GROUP_CONCAT(DISTINCT nom_espace) as   nom_espace,
                     GROUP_CONCAT(DISTINCT fonction_espace) AS fonction_espace,
                     GROUP_CONCAT(DISTINCT id_ouvrage_slab_wall) AS id_ouvrage_slab_wall,
                     GROUP_CONCAT(DISTINCT type_limit) AS type_limit, 
                     GROUP_CONCAT(DISTINCT type_ouvr) AS type_ouvr ')));

When I try to use for example nom_espace:

 $relespouv[$allelement['Relation']][12]=$relation->nom_espace;

I get the error:

Undefined property: stdClass::$nom_espace

Can any one help me please?

Limon Monte

You should move

array(DB::raw('GROUP_CONCAT(DISTINCT nom_espace) as   nom_espace,
    GROUP_CONCAT(DISTINCT fonction_espace) AS fonction_espace,
    GROUP_CONCAT(DISTINCT id_ouvrage_slab_wall) AS id_ouvrage_slab_wall,
    GROUP_CONCAT(DISTINCT type_limit) AS type_limit, 
    GROUP_CONCAT(DISTINCT type_ouvr) AS type_ouvr ')
)

from get() to select() like this

$relations = DB::table('relespouv')
    ->select(array(
        'id_ifc_espaces'
        DB::raw('GROUP_CONCAT(DISTINCT nom_espace) as   nom_espace,
        GROUP_CONCAT(DISTINCT fonction_espace) AS fonction_espace,
        GROUP_CONCAT(DISTINCT id_ouvrage_slab_wall) AS id_ouvrage_slab_wall,
        GROUP_CONCAT(DISTINCT type_limit) AS type_limit, 
        GROUP_CONCAT(DISTINCT type_ouvr) AS type_ouvr ')
    ))
    ->group_by('id_ifc_espaces')
    ->where('id_mn','=',$idmn)
    ->get();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to make a query with group_concat in sql server

From Dev

Query using group_concat is returning only one row

From Dev

Several group_concat in the same query

From Dev

Mysql GROUP_CONCAT and IN query

From Dev

Using MYSQL GROUP_CONCAT with sub query

From Dev

Mysql JOIN with GROUP_CONCAT in a complex query

From Dev

Optimize MySQL query for group_concat function

From Dev

Making a GROUP_CONCAT query more efficient

From Dev

SQL Query, Group_Concat of multiple left joins and nested queries

From Dev

how to use GROUP_CONCAT of two columns with query

From Dev

mySQL GROUP_CONCAT - Query

From Dev

Use GROUP_CONCAT query in Rails

From Dev

MySQL GROUP_CONCAT Query Excluding Records

From Dev

Mysql query using IN with group_concat result

From Dev

mysql query join group_concat

From Dev

Ordering a query that contains a subquery with a group_concat is very slow

From Dev

join query with group_concat, duplicate values

From Dev

Query using group_concat is returning only one row

From Dev

Error when I used GROUP_CONCAT on mysql query

From Dev

Using MYSQL GROUP_CONCAT with sub query

From Dev

GROUP_CONCAT not working in Sub-Query

From Dev

SQL Query, Group_Concat of multiple left joins and nested queries

From Dev

Query is not executing properly when I use GROUP_CONCAT with in keyward

From Dev

Mysql group_concat query gives error

From Dev

Select query with GROUP_CONCAT in mysql

From Dev

how to use select query in a Group_concat sub query in mysql

From Dev

Using Mysql GROUP_CONCAT in JOIN Query

From Dev

How to fix this query? Using GROUP_CONCAT

From Dev

Query with GROUP_CONCAT not working with PHP

Related Related

HotTag

Archive