0

Essentially I want to create a view in mySQL (phpmyAdmin) that queries a table called Equipment for a date range >=2018-12-1.

This is currently what I have, it is what is wrong with my syntax?

CREATE VIEW "Equipment_Date" AS SELECT * FROM "Equipment" 
WHERE "Ship_Del_Date" >= 2018-12-1;
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Al those double quotes should be backticks and the date should be in single quotes '2018-12-01' https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql – P.Salmon Apr 17 '19 at 06:47
  • Possible duplicate of [When to use single quotes, double quotes, and back ticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql) – Dharman Apr 17 '19 at 10:27

2 Answers2

1

Below query should work provided Ship_Del_Date column has datatype as DATETIME.

CREATE VIEW Equipment_Date AS SELECT * FROM Equipment
WHERE Ship_Del_Date >= '2018-12-1';

Use backticks instead of single quotes to enclose the table,column names only when the names are from mysql reserved keywords.

Vishal
  • 639
  • 7
  • 32
0

Use these to specify databases, tables and columns: `

And not these: "

Or simply just don't use any of these, if not necessary.

Then your SQL query will probably look like this: CREATE VIEW Equipment_Date AS SELECT * FROM Equipment WHERE Ship_Del_Date >= 2018-12-1;

Marvin Klar
  • 1,869
  • 3
  • 14
  • 32