views:

46

answers:

1

I have a SQL server table that has a list of Usernames and a list of points ranging from 1 to 10,000.

I want to display the number of points in my VB.NET program from the username given. For example, if I type in "john" in the first box the program will give me a message box saying whatever amount of points "john" has. I'm not really sure about SQL queries so please help me out here.

This is the Table Structure:

Usernames       Points
-----------------------------
John            20
Kate            40
Dan             309
Smith           4958
+1  A: 

Depending on the structure of the table, a suitable query is one of these:

select sum(points) as points
from usernames
where name='username';

or

select points
from usernames
where name='username';

or

select count(*) as points
from usernames
where name='username';
wallyk
Wait in the second one don't I need an asterik after select :select * points?
Kevin
The second one assumes there is one entry per username with a corresponding field containing all the user's points, so no, it doesn't need anything more.
wallyk