Jarvis Millan
Jarvis Millan

Reputation: 19

unwanted row when selecting rows

The following SELECT query doesn't work properly:

SELECT DISTINCT
    student.firstname,
    student.lastname,
    student.emailAddress,
    cast(memberslist.dateJoined as DATE) as dateJoined
FROM student, memberslist
WHERE 
    memberslist.orgName = 'Elite League of Information Technology Students'
    AND memberslist.joined = 'yes'

I have 2 tables: student and memberslist

memberslist table:
memberslist table

student table:
student table

and when I run the query, the result is the following:

SQL query results

I don't understand why it gives me the row pakalu when the WHERE was 'Elite League of Information Technology Student'

Upvotes: 0

Views: 26

Answers (1)

SMA
SMA

Reputation: 37023

Usage of implicit join is discouraged, you need following query:

SELECT s.firstname, s.lastname, s.emailAddress, cast(m.dateJoined as DATE) as dateJoined 
FROM student s INNER JOIN memberslist m
ON s.emailAddress = m.emailAddress
WHERE m.orgName = 'Elite League of Information Technology Students' 
  AND m.joined = 'yes'

Upvotes: 3

Related Questions