-1

Possible Duplicate:
I have mistake in database

create table Ticket (
ticket_id integer not null primary key,
AirlineName varchar not null,
CustomerName varchar,
fromCity varchar,
toCity varchar,
fltNo integer,
TicketDate date,
Dtime TIME,
Atime time,
price integer);

Please help me, I can't find the error. the program is my sql, and this is the error

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 'not null, CustomerName varchar, fromCity varchar, toCity varchar, fltNo inte' at line 3

Community
  • 1
  • 1
tara7el
  • 21
  • 2
  • You get an error message? It doesn't work as you expect? What happens or doesn't happen? – Bart Jul 26 '12 at 18:22
  • 1
    What database system are you using? Mysql, postgreSQL...? – Vitor Braga Jul 26 '12 at 18:22
  • 1
    Good point @VitorBraga, I can't tell what this is supposed to be just looking at it – James Webster Jul 26 '12 at 18:23
  • 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 'not null, CustomerName varchar, fromCity varchar, toCity varchar, fltNo inte' at line 3 – tara7el Jul 26 '12 at 18:23
  • Please don't post duplicates. Edit your original closed question to contain all the relevant content. Simply posting your question again is not the correct approach. – Bart Jul 26 '12 at 18:23
  • Edit your original question. Insert the error message and relevant details there. – Bart Jul 26 '12 at 18:24
  • 1
    @tara7el, don't just post comments. Edit the question to make it better – James Webster Jul 26 '12 at 18:29

2 Answers2

1

Now that I know it's MySQL:

Your varchars should have lengths (and phpMyAdmin appears to use INT instead of integer, but both seem to be valid)

CREATE TABLE Ticket(
ticket_id INT PRIMARY KEY ,
AirlineName VARCHAR( 255 ) NOT NULL ,
CustomerName VARCHAR( 255 ) ,
fromCity VARCHAR( 255 ) ,
toCity VARCHAR( 255 ) ,
fltNo INT,
TicketDate DATE,
Dtime TIME,
Atime TIME,
price INT
);
James Webster
  • 31,873
  • 11
  • 70
  • 114
0

Possible solution...
In your case, you use mysql, so this is the correct syntax.
Remember to put the VARCHAR length...

 create table Ticket (
        ticket_id int not null,
        AirlineName varchar(255) not null,
        CustomerName varchar(255),
        fromCity varchar(255),
        toCity varchar(255),
        fltNo integer,
        TicketDate date,
        Dtime TIME,
        Atime time,
        price int, 
        primary key (ticket_id)
    );
Vitor Braga
  • 2,173
  • 1
  • 23
  • 19