Link to home
Start Free TrialLog in
Avatar of Tom Powers
Tom Powers

asked on

How do I use two parameters in a SQL Select statement

I created a flat table and I want to pull two different teams out of table I am a little lost cause I'm using this sql select statement

SELECT ID, EmailAddress, ImageUrl, Team, Message, DateX, Upload FROM BaseballMessageLog WHERE (Team = @Team) AND (Team = @Team2) I need two teams for a ASP.NET PAGE. Visual Studio allows you to select the controls that you are going to use as parameters. Any Suggestions
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

If you need two 'teams' of data in one set, then...

SELECT ID, EmailAddress, ImageUrl, Team, Message, DateX, Upload
FROM BaseballMessageLog
WHERE (Team = @Team) OR (Team = @Team2)  - or WHERE Team IN (@Team, @Team2)

The way you have it coded it's testing the same value to be equal to @team and @team2, and unless those parameters are the same value it would return no rows.
Avatar of Tom Powers
Tom Powers

ASKER

I am not a Sql Expert but I can move my way through but I got 3  ERROR Messages 1 is the select statement and the other two are when SQL asked for parameters for the teams at first it didn't like the -    in - or WHERE Team IN (@Team, @Team2) then incorrect syntax by WHERE CLAUSE I got screen shots if it helps again I'm not a wizard when it comes to sql.User generated image
User generated image

User generated imageAny
Of your thoughts would be greatly apprecuiated.Thanks
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very Very Nice I was researching but the best way was to hit up you EE Guys you guys are Lifesavers. Thanks
Tom
Very Nice Work You EE Guys are heroes.Thanks
Tom
Yeah we're not half bad once we get our gallon of coffee in us.

Thanks for the grade.  Good luck with your project.  -Jim