From: Mike Johnson [mailto:mike@stripped]
> From: Koon Yue Lam [mailto:kisstech@stripped]
> > the problems is, when I want to query both student, address
> > and phone num, the sql will be
> > select * from student s, address a, phone_num n
> > where s.student_id = a.sudent_id
> > and s.student_id = n.student_id
> > it won't provide a nice result as data of student are
> > repeated in every row, address and phone_num's data are
> > repeated in certain rows
> > The output is not suitable for reporting and may I ask what
> > is the better way of design to handle the above case ?
> It's good DB design, but you need to not `select *' but the specific
> fields you'd like.
> An example of might be:
> SELECT s.name, s.age, a.street_name, n.num, n.extension
> FROM students s
> JOIN address a ON a.student_id = s.student_id
> JOIN phone_num n ON n.student_id = s.student_id
I just realized I sort of misread your question (or, rather, only read
the first half of it).
I guess my question is whether or not you're using some sort of
front-end scripting language to retrieve results or using the MySQL
client straight. If the former, you can definitely work with the data in
the way you'd like, but as for the latter, the MySQL client itself
wasn't actually meant to be used as any sort of reporting tool. It
certainly isn't made to make data look "nice." :)
Might you be using PHP, Perl, or something else like that?
Mike Johnson Smarter Living, Inc.
Web Developer www.smartertravel.com
mike@stripped (617) 886-5539