-2

What is wrong with the syntax? its been wrecking my head for ages. Could someone scan their eyes over it please?

SELECT C_Name, C_StreetNumber, C_StreetName, C_Postcode, C_County, C_Tele, C_Website, Contact_Forename, Contact_Surname, Contact_Email, Job_Type, Job_Price
FROM Company, Jobs ON Company.Company_ID = Jobs.Company_ID 
WHERE Company.C_County LIKE %belfast% AND Jobs.Job_Type LIKE %virus%
Andrew Glass
  • 423
  • 2
  • 7
  • 18
  • 4
    Remove the comma and replace it with the word `JOIN`... `FROM Company JOIN Jobs` You're also missing single quotes around your like clauses -- `like '%belfast%'`. – sgeddes Nov 25 '15 at 23:02

1 Answers1

1

You need to use explicit JOIN when you use ON. If not you need to join the two tables in the WHERE clause. Also you have to select columns that don't have the same column in both tables otherwise you need to select them as table.column. e.g.

SELECT Company.C_Name, Company.C_StreetNumber, C_StreetName, C_Postcode, C_County, C_Tele, C_Website, Contact_Forename, Contact_Surname, Contact_Email, Job_Type, Job_Price
FROM Company
INNER JOIN Jobs
ON Company.Company_ID = Jobs.Company_ID 
WHERE Company.C_County LIKE '%belfast%' AND Jobs.Job_Type LIKE '%virus%'

Have a look here.

Community
  • 1
  • 1
Kostas Mitsarakis
  • 4,772
  • 3
  • 23
  • 37