0

I am practising mysql in command line. I have a database named ticket_system which in turn has a table named train

create table ticket_system.Train
(
    Train_no            int(10) PRIMARY KEY,
    Name                varchar(10),
    source              varchar(10),
    destination         varchar(10),
    start_time          TIME,
    reach_time          TIME,
    traveltime          int(10),
    distance            int(10), 
    class               int(10),
    days                int(10),
    type                varchar(10)
    );

This was what I used to make a table and its columns which worked fine. But now when I am inserting data in the table columns.

INSERT INTO ticket_system.Train (Train_no, Name, source, destination, start_time, reach_time, traveltime, distance, class, days, type) values(1, ‘raja’, ‘delhi’ , ‘patna’ , ’120000’ , ’130000’ , 1 , 100 , 1 , 1, ‘2nd’ );

I am getting error

ERROR 1054 (42S22): Unknown column 'raja' in 'field list'

I dont understand why is this error . The field Name datatype is set to varchar(10) and "raja" should fit into that . Can someone point me where I am doing wrong?

shashank
  • 19
  • 1
  • 8
  • Use quotes not backticks for string literals, ' not ` – Mihai Sep 27 '16 at 19:14
  • You should code with a text editor rather than a word processor. Different quotes normally have different meanings. – Álvaro González Sep 27 '16 at 19:15
  • @Mihai I have used single quotes only . I am amazed to see that it has turned into backticks which I did not type in my text editor – shashank Sep 27 '16 at 19:22
  • @shashank That's because of what I said: if you use a program that's intended to general writing it often has smart quotes and other auto-correction features that are entirely undesired when producing code. Which program are you using? – Álvaro González Sep 28 '16 at 07:30

1 Answers1

0

You need to wrap your columns that are of string (text, varchar, char) data type with single quotes '.

INSERT INTO ticket_system.Train 
  (Train_no, Name, source, destination, start_time, reach_time, traveltime, distance, class, days, type) 
values
  (1, 'raja', 'delhi' , 'patna' , '120000' , '130000' , 1 , 100 , 1 , 1, '2nd' );
Kamil Gosciminski
  • 16,547
  • 8
  • 49
  • 72
  • I used single quotes but I don't know how in mac's default text editor it was converted into backticks. When I re-wrote things in sublime it worked. Thank you for your help – shashank Sep 27 '16 at 19:26