Help writing an If else statement

Help writing an If else statement

am 06.07.2007 19:46:13 von JJ297

Hello I'm a newbie to programming and need help writing an if
statement.

I have a database set up in SQL with the following fields:

Category Questions Answers

I only want one category to appear for all of the questions and
answers submitted for that category. The way I have it set up now all
if a question is submitted for the same category then the category
will list twice and a one question under each other.

How do I write something if I Dim Category

If it's the same category but a different question just list that
question under that category. If it's a new category list that
category and the questions and answers under that

Re: Help writing an If else statement

am 07.07.2007 00:00:36 von Erland Sommarskog

JJ297 (nc297@yahoo.com) writes:
> Hello I'm a newbie to programming and need help writing an if
> statement.
>
> I have a database set up in SQL with the following fields:
>
> Category Questions Answers
>
> I only want one category to appear for all of the questions and
> answers submitted for that category. The way I have it set up now all
> if a question is submitted for the same category then the category
> will list twice and a one question under each other.
>
> How do I write something if I Dim Category
>
> If it's the same category but a different question just list that
> question under that category. If it's a new category list that
> category and the questions and answers under that

I am afraid that I can only answer with the standard recommendation that
you post:

o CREATE TABLE statements for your table(s).
o INSERT statement with sample data.
o The desired output given the sample.

This helps to clarify what you are asking (which I currently do not
understand), and also makes it easy to develop a tested solution.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx

Re: Help writing an If else statement

am 07.07.2007 03:31:18 von Ed Murphy

JJ297 wrote:

> Hello I'm a newbie to programming and need help writing an if
> statement.
>
> I have a database set up in SQL with the following fields:
>
> Category Questions Answers
>
> I only want one category to appear for all of the questions and
> answers submitted for that category. The way I have it set up now all
> if a question is submitted for the same category then the category
> will list twice and a one question under each other.
>
> How do I write something if I Dim Category
>
> If it's the same category but a different question just list that
> question under that category. If it's a new category list that
> category and the questions and answers under that

This sounds like it should be done in a separate reporting
layer, using Crystal Reports or something similar.

Re: Help writing an If else statement

am 08.07.2007 16:00:36 von Joe Celko

Why are you formatting data in the back end? The basic principle of a
tiered architecture is that display is done in the front end and never
in the back end. This a more basic programming principle than just
SQL and RDBMS.