CiviBeginner
CiviBeginner

Reputation: 1

mysql query for getting corresponding values of similar rows

I have a database table with contents as follows:

A        B
chap1   c1
chap1   c2
chap1   c3

I want to get all the result.i.e in the select dropdown I am having chap1 as 3 options.For each selected option I have to get the corresponding c1/c2/c3 values. Any help will be appriciable.Thanks in advance.

Upvotes: 0

Views: 48

Answers (2)

gauravK
gauravK

Reputation: 197

Mysql query will be

 SELECT B FORM `table` WHERE A = 'chap1' 

Upvotes: 1

R. Horber
R. Horber

Reputation: 510

Use the function group concat:

SELECT GROUP_CONCAT(DISTINCT b)
FROM `table`

Here's a link to the function.

Upvotes: 0

Related Questions