CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 SQL Question.

Print topic Send  topic

Author Message
acapp


Posts: 31
Posted: 04/19/2004, 2:22 PM

Hi Gurus,

I've looked all over for an answer to this. Maybe someone has something they could share.

I have a column that is an id. I can count that id and get the total of
how many times that id is in the database.

What I would like to do is to display only that id information on a page.
The problem is that the id is the only thing that is unique about the record. So a regular count(id) Where id = foobar won't work.

The only thing I can think of is to use the count to display the counted ids. How can I do this?

This is what I'd like to see

id name
25 Alice
25 Bob
25 Jane
29 John

So the total count of the id is 3 for id 25. I want only to display id 25.
I don't want to show John.

Your help is appreciated.

I'm using PHP, MySQL and CCS 2.2.60
View profile  Send private message
peterr


Posts: 5971
Posted: 04/20/2004, 1:28 AM

I don't understand who and how makes the decision about which id should be displayed? Why "Where id = 25" or "Where id = user_selected_id" wouldn't work?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
acapp


Posts: 31
Posted: 04/20/2004, 5:19 AM

It is difficult sometimes to explain these things with this medium.

I think the Where id = user_selected_id is where I want to go. Is this SQL or PHP programming or both? I'd like just to use SQL if I could, but if not then I'll do it anyway that works.

Thanks
Andrew
View profile  Send private message
peterr


Posts: 5971
Posted: 04/20/2004, 12:38 PM

Well, if the user has the choice of selecting the ID that he wants to see, then usually this is done via a URL. For example the user would see the list of ID's and then click on one that he wants to see the details for.
This method is used in many of our examples but I'm not sure if this is what you're trying to implement.

For example in our Employee Directory example ( http://examples.codecharge.com/EmployeeDirectory/Default.php ) a user selects an employee by clicking on the link and then goes to a URL that contains "emp_id=XYZ".
In the same way you can create a list of ID's with links that contain the "ID" parameter. Then on another page (or the same one) you can have a Grid that displays only those records that match the selected ID. You'd do this by creating Where Parameters in yourd "Data Source" property/dialog of the 2nd (destination) grid.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Gymsmoke
Posted: 04/27/2004, 9:21 AM

If this is what I think it is, you would something along the following:

Select id, name from foo where id = {user_selected_id} group by id;

You can also add an inner join to the same table, adding a count(recs). and then display the count in a variable field on your grid.

hth

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.