1

I have the entire table being pulled in but I want it set up so the only rows that are displayed are the ones with specific information in one column.

Here is my SELECT statement:

SELECT [Day], aoc, ryg, reasoning, notes FROM dbo.ryg_conditions ORDER BY aoc ASC,[Day] DESC 

But I only want to display rows that have "Administration" in the aoc column and then sort those by the date.

I'm new to ASP and databases, please help?

2
  • 2
    Can't you add a where-clause to your query? it always best to select just the records you need. Selecting records you don't need is a waste of time and performance :-) Commented Nov 4, 2011 at 13:18
  • Awesome, thank you. I didn't know about WHERE. Extreme noob here. Commented Nov 4, 2011 at 13:22

3 Answers 3

2

you would usually let the database do the initial restriction

something like this:

SELECT [Day], aoc, ryg, reasoning, notes 
FROM dbo.ryg_conditions 
WHERE aoc ='Administration'
ORDER BY aoc ASC,[Day] DESC 
Sign up to request clarification or add additional context in comments.

Comments

1

You need to look into WHERE

In your case, you would add to your query:

SELECT [Day], aoc, ryg, reasoning, notes 
FROM dbo.ryg_conditions 
WHERE aoc = 'Administration'
ORDER BY aoc ASC,[Day] DESC 

Comments

1

You need to use a WHERE statement.

SELECT [Day], aoc, ryg, reasoning, notes 
FROM dbo.ryg_conditions 
WHERE aoc = 'Administration'
ORDER BY aoc ASC,[Day] DESC 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.