NoviceToDotNet
NoviceToDotNet

Reputation: 10805

How to match two fields in an SQL query?

Please correct the query.

It is working but it gives the wrong result, I have database tables that look like this.

[3rdi_EventsRolePrice] :-EventID, RoleID, RolePrice
[3rdi_EventsRolePrice]:- FirstName, LaastName And EventID

I want to get FirstName, LastName, RoleID by joining these two, and I am passing an event value as a parameter which is 13 in my case just for getting result.

SELECT ep.FirstName, ep.LastName, erp.RoleID 
from [3rdi_EventParticipants] ep,[3rdi_EventsRolePrice] erp
WHERE  ep.EventID==erp.EventID and erp.EventID='13'

I want to match where these two things "ep.EventID==erp.EventID" are equal, and their value is also 13. My query is also working syntaxically correct but I get a thoroughly wrong result.

Upvotes: 0

Views: 405

Answers (2)

bAN
bAN

Reputation: 13825

SELECT 
 ep.FirstName,
 ep.LastName,
 erp.RoleID

 FROM [3rdi_EventParticipants] ep
 INNER JOIN [3rdi_EventsRolePrice] erp
 ON  ep.EventID = erp.EventID 
 WHERE erp.EventID='13'

I think it will work..

Upvotes: 3

Habax
Habax

Reputation: 1332

ep.EventID==erp.EventID to ep.EventID=erp.EventID

Upvotes: 1

Related Questions