T1
F1 F2 F3 F4
a 2 2 NULL
a 2 3 UK
But i want only the result is a 2 2,3 UK
if i do select
How to achieve this ?
i am looking out the result :a 2 2,3 UK and 2,3 is F3 field
T1
F1 F2 F3 F4
a 2 2 NULL
a 2 3 UK
But i want only the result is a 2 2,3 UK
if i do select
How to achieve this ?
i am looking out the result :a 2 2,3 UK and 2,3 is F3 field
U can use the query as given below -
select * from T1 where F4 is not null
Is this what you are looking at?
If you want to group by F1 and F2 and get all values of F3 in one string, separated by a comma (which seems to be what you're asking) then you will have to use GROUP_CONCAT.
select F1, F2, GROUP_CONCAT(F3 ORDER BY F3) as F3, F4 from T1 group by F1, F2
BTW Make sure you read the documentation on GROUP_CONCAT (see link above), because this field will be truncated if it exceeds a maximum length (1024 characters per default)! The value you get for F4 might not be what you expect though (since the query is using one of the many pesky "features" of MySQL)... It would make more sense if F4 contained UK for both rows, then you could add F4 to the group by-clause.