Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Database join questions

0

53 views

there are two tables in db

Book{
isbn integer, //primary key
title char(50),
publisher char(30),
year integer
}

Author{
isbn integer,  //foreign key 
name String,
rank integer,  // indicate whether it is author1, author2, author3,...,authorn
}

write a sql statement to output book in this way Title author1 author2 publisher, year.

The logic is selecting two records from Author table according to isbn then combine to the record in Book and output it. I think we can do it in MySQL?

THANKS.

asked June 24, 2011 10:24 am CDT
posted via StackOverflow

1 Answer

0
 

Try GROUP_CONCAT

SELECT b.title, group_concat(a.name separator ',')
FROM book b join author a on b.isbn = a.isbn
group by b.title

answered June 24, 2011 11:24 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
Regex questions
March 8, 2011
DNS record questions.
March 22, 2011
Some apache log questions
February 13, 2011