Print Page | Close Window

Displaying Conditional Database Data

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=27045
Printed Date: 29 March 2026 at 2:48am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Displaying Conditional Database Data
Posted By: kennywhite
Subject: Displaying Conditional Database Data
Date Posted: 27 February 2009 at 9:34pm
Hello,
 
I am working on a simple webpage to track and edit assets. I have the database and the basic code out of the way so that I can have one page that will display every asset and information about it.
 
I would like to be able to switch to a department view, where, obviously, each device in the particular department will be displayed. I would also like to be able to display a total count of each specific model number.
 
This is ran on an Access database. I have been messing around with Access trying to figure out how to make, say, a table for each department that receives it's data from the main table (the one that includes every single asset). Is there no simple way to just make a table take data from another, the way you can reference cells in Excel?
 
I set up a query to count each model number. That was fairly simple, but how do I force that query to spit that data out into a separate table? Or is it possible to use ASP to display data in a query the same as it would from a table (know what I mean?)?
 
Or, instead of making Access do all of the work, which just seemed easier to me at first, can I filter for certain data in the database using ASP and display only the rows that would contain a cell that reads, DEPARTMENT A or DEPARTMENT B? Something like that?
 
I hope I posed my questions good enough and didn't make them too confusing.
 
 



Replies:
Posted By: WebWiz-Bruce
Date Posted: 02 March 2009 at 9:39am
In SQL Server you can make a view which represents a virtual table created from the data of other tables. Not sure though if this is available in Access.

However you should be able to construct an SQL Query that pulls only the data you need from a single or multiple tables.

For example in your case you could have:-

SELECT * FROM table_name WHERE field_name = 'DEPARMENT A';


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: kennywhite
Date Posted: 02 March 2009 at 6:44pm
Originally posted by WebWiz-Bruce WebWiz-Bruce wrote:

In SQL Server you can make a view which represents a virtual table created from the data of other tables. Not sure though if this is available in Access.

However you should be able to construct an SQL Query that pulls only the data you need from a single or multiple tables.

For example in your case you could have:-

SELECT * FROM table_name WHERE field_name = 'DEPARMENT A';
 
That worked easily! Thank you so much!
 
Is there a way that I could count how many instances of particular entries that I have? For instance, if I want to know how many of a certain model we have. Could I add in a function to give the sum of how many times "Model XX01" appears in the column named "Models"?


Posted By: Scotty32
Date Posted: 02 March 2009 at 10:14pm
see http://www.w3schools.com/sql/sql_func_count.asp" rel="nofollow - this page on w3schools.com

-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: kennywhite
Date Posted: 05 March 2009 at 9:27pm
Originally posted by WebWiz-Bruce WebWiz-Bruce wrote:

In SQL Server you can make a view which represents a virtual table created from the data of other tables. Not sure though if this is available in Access.

However you should be able to construct an SQL Query that pulls only the data you need from a single or multiple tables.

For example in your case you could have:-

SELECT * FROM table_name WHERE field_name = 'DEPARMENT A';
 
I've not been able to figure out how to filter by two different columns. I've tried
 
SELECT * FROM table_name WHERE field_name = 'DEPARMENT A', WHERE field_name = 'PRODUCT_TYPE B';
 
I've also tried it without the comma, without the "WHERE" and all of that. Would you mind telling me how to properly do this?
 
Thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net