MySQL Group by two columns from one table


i struggling mysql select trying group 2 different columns within single table. basically, example below shouldd able see id key column, , threadid relates key column.

 

----------------------------------

| id | threadid | heading      |

----------------------------------

| 1  | 0        | first heading    |

| 2  | 0        | second heading |

| 3  | 2        |                       | <--(no heading needed relates id 2)

| 4  | 2        |                       | <--(no heading needed relates id 2)

| 5  | 0        | third heading  |

| 6  | 5        |                       | <--(no heading needed relates id 5)

| 7  | 5        |                       | <--(no heading needed relates id 5)

----------------------------------

 

 

i can working great grouping by, problem getting following results:

 

----------------------------------

| id | threadid | heading     |

----------------------------------

| 1  | 0        | first heading  |

| 4  | 2        |                      | <--(heading of id 2 disappeared)

| 7  | 5        |                      | <--(heading of id 5 disappeared)

----------------------------------

 

 

basically, if key column item doesn't have related record, getting heading printed desired, if there related record, heading disappears. question is, how can retain heading?

 

 

here's recordset select , variable:

 

select *

from tbl_forumposts join tbl_users on tbl_forumposts.fld_fuserid = tbl_users.userid

where fld_fshow = 1

group fld_fthreadid, colname

order fld_freplydate desc

 

name: colname

type: int

default: -1

runtime: $_get['fld_fid']

 

 

with above recordset , variable, able results within db table 99 records down 16, losing headings. it's because there isn't 1 in record, need tie key record can pull place, how?

 

 

thanks in advance.

group fld_fthreadid, colname

 

first of all, value of colname passing in? in other words, 2 columns in group clause?



More discussions in Develop server-side applications in Dreamweaver


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account