This is a discussion on group_concat in MySQL within the Database Support forums, part of the Web Development category; Originally Posted by Murali Hi, Have u noticed one thing, Code: SELECT GROUP_CONCAT(Field_name) FROM table_name LIMIT 0,10; But ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#21
| |||
| |||
| Quote:
SELECT GROUP_CONCAT(Field_name) FROM table_name LIMIT 1,10; i didn't get any output from the quey, it shows that the GROUP_CONCAT() Function captures the values from the field and then applies the LIMIT CLAUSE. This may be reason....
__________________ -Murali.. |
|
#22
| |||||
| |||||
| Quote:
Found a new one, check this out. In MYSQL mysql> SELECT myfield FROM test_cast; Quote:
Quote:
In ORACLE SELECT CAST('123'AS INTEGER) AS VAL FROM DUAL; Quote:
Quote:
__________________ -Murali.. |
|
#24
| |||
| |||
| Quote:
Code: mysql> SELECT GROUP_CONCAT(CAST(MyTable_Id AS BINARY)),GROUP_CONCAT(CAST(MyTable_Value AS BINARY)) FROM MyTable; Code: mysql> show warnings; +---------+------+--------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------+ | Warning | 1260 | 1 line(s) were cut by GROUP_CONCAT() | +---------+------+--------------------------------------+ 1 row in set (0.00 sec)
__________________ -Murali.. |
|
#25
| |||
| |||
| Hi, In group_concat() function SELECT GROUP_CONCAT(name) FROM employee LIMIT 2 -- returns all name while using group_conact() function with limit clause retruns unexpected result . so change the query like SELECT GROUP_CONCAT(A.NAME) FROM (SELECT * FROM E_EMPLOYEE LIMIT 2) A -- returns only two name. Thanks, V.Kumaresan. Last edited by kumaresan : 09-24-2007 at 10:58 PM. |
|
#27
| |||
| |||
| Quote:
group_concat is getting only 4294967296(2^32) chars at the Maximum in a select query
__________________ With, J. Jeyaseelan Everything Possible |
|
#29
| |||
| |||
| Eliminating the duplicates using GROUP_CONCAT() Code: mysql> CREATE TABLE members (ID INTEGER PRIMARY KEY,names VARCHAR(100)); Query OK, 0 rows affected (0.04 sec) mysql> INSERT INTO members VALUES (1,'Ragavan'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO members VALUES (2,'Ragavan~'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO members VALUES (3,'Ragavan'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO members VALUES (4,'Rajesh'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO members VALUES (5,'Rahul'); Query OK, 1 row affected (0.00 sec) mysql> SELECT GROUP_CONCAT(names)FROM members; +---------------------------------------+ | GROUP_CONCAT(names) | +---------------------------------------+ | Ragavan,Ragavan~,Ragavan,Rajesh,Rahul | +---------------------------------------+ 1 row in set (0.00 sec) -- Now getting the Distinct Names using GROUP_CONCAT() mysql> SELECT GROUP_CONCAT(DISTINCT names)FROM members; +-------------------------------+ | GROUP_CONCAT(DISTINCT names) | +-------------------------------+ | Ragavan,Ragavan~,Rajesh,Rahul | +-------------------------------+ 1 row in set (0.00 sec)
__________________ -Murali.. |
|
#30
| |||
| |||
| hi, If you want to handle group_concat() result with names and want use the result in another query , consider the following table CREATE TABLE employee (id int NOT NULL, name varchar(40) , deptid int , salary bigint , address varchar , PRIMARY KEY (id) ); insert into employee values(1,'ram',10,20000,'vellore') ; insert into employee values(2,'raja',10,10000 ,'chennai') ; select group_concat(concat('''',name,''''))into @a from employee; -- this query returns 'ram','raja' to @a set @s:=concat('select * from employee where name in (',@a,');'); prepare stm1 from @s; execute stm1 ; deallocate prepare stm1; RESULT ------- id name deptid salary address --------------------------------------------------- 1 ram 10 20000 vellore 2 raja 10 10000 chennai |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL | lldcrb328 | PHP Programming | 2 | 02-15-2009 09:45 PM |
| I Can Help With MYSQL | theseokit | Database Support | 9 | 01-21-2009 11:01 PM |
| php-mysql | lekshmy | PHP Programming | 0 | 01-21-2009 10:58 PM |
| Why to use MySQL | Amisha_Sharma | Database Support | 1 | 01-07-2009 07:56 PM |
| multiple group_concat problem | fncll | Database Support | 4 | 11-30-2007 12:06 AM |
Our Partners |