Jason G
Jason G

Reputation: 17

How can I only display certain rows from a database table in ASP?

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?

Upvotes: 1

Views: 160

Answers (3)

Miika L.
Miika L.

Reputation: 3353

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 

Upvotes: 1

Doozer Blake
Doozer Blake

Reputation: 7797

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 

Upvotes: 1

Randy
Randy

Reputation: 16677

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 

Upvotes: 2

Related Questions