Bonjour,
je voudrais concatener plusieur champs d'une même table, sachant que certain de ces champs ont pour valeur NULL.
Par exemple, voici ma table:
Si j'utilise CONCAT(), je perds une ligne:Code:
1
2
3
4
5
6
7
8
9
10
11 mysql> select * from temp; +-------+-------+-------+ | chps1 | chps2 | chps3 | +-------+-------+-------+ | tut | tot | tyt | | tat | tit | tyt | | tet | NULL | tyt | | tat | | tyt | +-------+-------+-------+ 4 rows in set (0.02 sec)
Si j'utilise concat_ws(), c'est mieu, mais sur la ligne 3, je perds un champs :Code:
1
2
3
4
5
6
7
8
9
10
11 mysql> select concat(chps1,chps2,chps3) from temp; +---------------------------+ | concat(chps1,chps2,chps3) | +---------------------------+ | tuttottyt | | tattittyt | | NULL | | tattyt | +---------------------------+ 4 rows in set (0.03 sec)
Existe t'il un moyen de concatener des chaines contenant NULL avec MySQL??Code:
1
2
3
4
5
6
7
8
9
10
11 mysql> select concat_ws(';',chps1,chps2,chps3) from temp; +----------------------------------+ | concat_ws(';',chps1,chps2,chps3) | +----------------------------------+ | tut;tot;tyt | | tat;tit;tyt | | tet;tyt | | tat;;tyt | +----------------------------------+ 4 rows in set (0.00 sec)
Stos