Counting in a MySQL DB
Posted: Thu May 24, 2007 2:46 am
Hello,
I don't really know how to explain what I need but here is an example. Hope you can understand and can give me some tips.
I have a 5 records db.
ID shop_name cards pos_id
1 shop1 CA PS01
2 shop1 CA PS02
3 shop2 CF PS03
4 shop2 CA PS04
5 shop3 CF PS05
The actual db has around 5000 records and 12 fields but if I can sort it for this example is more the enough. Here is what I want to do: I want to see how many pos I have that accept CA cards. This is simple. How do I see how many shops I have that accept CA cards? The only thing I thought to do is to sort the db by shop name and the compare a record with the next one. Is this the only way? Will this method slow down the server a lot? There will be around 5 users performing reports like this on the 5000 records db. Thanks.
I don't really know how to explain what I need but here is an example. Hope you can understand and can give me some tips.
I have a 5 records db.
ID shop_name cards pos_id
1 shop1 CA PS01
2 shop1 CA PS02
3 shop2 CF PS03
4 shop2 CA PS04
5 shop3 CF PS05
The actual db has around 5000 records and 12 fields but if I can sort it for this example is more the enough. Here is what I want to do: I want to see how many pos I have that accept CA cards. This is simple. How do I see how many shops I have that accept CA cards? The only thing I thought to do is to sort the db by shop name and the compare a record with the next one. Is this the only way? Will this method slow down the server a lot? There will be around 5 users performing reports like this on the 5000 records db. Thanks.