Monday, February 27, 2012

Help writing an If else statement

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 thatJJ297 (nc297@.yahoo.com) writes:

Quote:

Originally Posted by

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/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||JJ297 wrote:

Quote:

Originally Posted by

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.|||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.

No comments:

Post a Comment