I am trying to run this sql query in PHPMyAdmin:
--create a mysql contact table
--delete contact table if already exists
DROP TABLE IF EXISTS contact;
--create new table named contact with fields as specified
CREATE TABLE contact(
contactID int PRIMARY KEY,
name VARCHAR(50),
company VARCHAR(30),
email VARCHAR(50)
);
--add these to the table
INSERT INTO contact VALUES (0, 'Bill Gates', 'Microsoft', 'bill@micro.com');
INSERT INTO contact VALUES (1, 'Larry Page', 'Google', 'larry@google.com');
--displays whats in this
SELECT * FROM contact;
I thought that in sql this is considered a comment: --I'm a comment
However PHPMyAdmin isn't accepting it.
I get this error:
SQL query:
--create a mysql contact table
--delete contact table if already exists DROP TABLE IF EXISTS contact;
MySQL said:
Documentation
1064 - You have an error in your SQL syntax;
Check the manual that corresponds to your MySQL server version for the right syntax to
use near '--create a mysql contact table --delete contact table if already exists
DROP T' at line 1
I get the same error with the same code on these sql checkers also:
http://www.piliapp.com/mysql-syntax-check/ http://sqlfiddle.com/
You need an interval/space after the --
Otherwise it's not considered a valid comment in MySQL.