Reply to Re: question about a query

Your name:

Reply:


Posted by Roy Harvey on 06/28/07 20:27

n Thu, 28 Jun 2007 12:44:17 -0700, nina297 <nina.childress@ssa.gov>
wrote:

>I've written this query:
>
>select distinct topics, questions, answer
>from topics AS A, QuesNans AS B
>where A.topicid = B.topicid
>order by a.topics
>
>The results are:
>Topic Questions Answers
>Topic Four Question 1 Answer to question 1
>Topic One Quesstion 2 Answer to question 2
>Topic One Question 1 Answer to question 1
>Topic Three Question 1 Answer to question 1
>Topic Two Question 2 Answer to question 2
>
>How do I get one topic listed but all of the questions that go with
>that topic?

With a WHERE clause test? Or perhaps I do not understand the
question.

SELECT topic, question, answer
FROM Topics AS A
JOIN QuesNans AS B
ON A.topicid = B.topicid
WHERE A.topic = 'Topic One'
ORDER BY a.topic

By the way, it is common to make table names plural, and column names
singular. And it is much preferred to use the SQL-92 join syntax and
leave the WHERE clause for the rest tests to include/exclude rows (at
least in so far as they do not break OUTER joins.)

Roy Harvey
Beacon Falls, CT

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация