Here is my table structure:
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY
,lead_id INT NOT NULL
,form INT NOT NULL
,value VARCHAR(20) NOT NULL
,field_no INT NOT NULL
);
INSERT INTO my_table VALUES
( 1 ,1 ,1 ,'John' ,5),
( 2 ,1 ,1 ,'Smith' ,6),
( 3 ,1 ,1 ,'987654321',3),
( 4, 2 ,1 ,'Sam' ,5),
( 5 ,2 ,1 ,'Long' ,6),
( 6 ,2 ,1 ,'42254545' ,3),
( 7 ,3 ,2 ,'23' ,12),
( 8 ,3 ,2 ,'Foo' ,5),
( 9 ,3 ,2 ,'Bar' ,3),
(10 ,4 ,1 ,'Simon' ,5),
(11 ,4 ,1 ,'Rhodes' ,6),
(12 ,4 ,1 ,'659874' ,3);
http://sqlfiddle.com/#!2/77f80
Is it possible to select the following in just one SELECT statement:
RESULT ROW 1: "John Smith", "987654321"
RESULT ROW 2: "Sam Long", "42254545"
RESULT ROW 3: "Simon Rhodes", "659874"
ie. If this was on ONE row, the select would be:
SELECT CONCAT(Name," ", Surname) as fullname
, employeeNo from tableA WHERE form = "1" group by lead_id
Please help