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
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
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.
Any
Of your thoughts would be greatly apprecuiated.Thanks
Any
Of your thoughts would be greatly apprecuiated.Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very Very Nice I was researching but the best way was to hit up you EE Guys you guys are Lifesavers. Thanks
Tom
Tom
ASKER
Very Nice Work You EE Guys are heroes.Thanks
Tom
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
Thanks for the grade. Good luck with your project. -Jim
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.