Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Sql query

Hello,

I am using a query  
      SELECT E.EmployeeID, E.Firstname,E.Lastname,E.Datejoined FROM                
       B35_Employees E  INNER JOIN B35_Cars C
       ON E.EmployeeID = C.EmployeeID
       WHERE (C.RegistrationNumber is not null and           C.RegistrationNumber <> '')order by E.Lastname ASC
which is returning duplicate rows

4      HQU      A      2000-01-01 00:00:00.000
2      CDE      B      2000-12-13 00:00:00.000
3      HIU      B      1998-03-01 00:00:00.000
1      ABC      C      2008-01-12 00:00:00.000
1      ABC      C      2008-01-12 00:00:00.000
1      ABC      C      2008-01-12 00:00:00.000

Any suggestion on using left join so that I dont get the repetition.
Cheers
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
Avatar of RIAS

ASKER

Cheers mate!
Avatar of RIAS

ASKER

Just executed the query
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ','.

Cheers
Double-click on the error message, watch the cursor jump to the offending line, then tell us what line that is.  Looking at the code I posted I don't see any orphan commas that would cause that error.