Results 1 to 3 of 3

Thread: What's wrong with this SQL?

  1. #1
    Join Date
    Feb 2003
    Posts
    1

    Angry What's wrong with this SQL?

    I've been trying to create my tables the easy way by using phpMyAdmin. However, when I try to create a table, I get an error message. Here is the SQL phpMyAdmin is using:

    CREATE TABLE 'quizzes' (
    'qName' VARCHAR (32) NOT NULL ,
    'qAuthor' VARCHAR (32) NOT NULL ,
    'qIDnum' INT NOT NULL AUTO_INCREMENT ,
    'qIDname' VARCHAR (16) NOT NULL ,
    'qPass' VARCHAR (32) NOT NULL ,
    'qMoreInfo' VARCHAR (255) NOT NULL ,
    'qRandQuest' TINYINT NOT NULL ,
    'qRandChoice' TINYINT NOT NULL ,
    'qTimeLimit' INT NOT NULL ,
    'qResultsOption' TINYINT NOT NULL ,
    'qWordBankUsed' TINYINT NOT NULL ,
    'qWordBankID' INT NOT NULL ,
    'qQuestions' VARCHAR (32) NOT NULL ,
    'qStudents' VARCHAR (32) NOT NULL ,
    'qListNames' VARCHAR (32) NOT NULL ,
    'qTypesName' TINYINT NOT NULL ,
    PRIMARY KEY ('qIDnum') ,
    UNIQUE (
    'qIDname'
    )
    )

    Why is this failing?

  2. #2
    Join Date
    Feb 2003
    Posts
    1
    from what i can see you have a problem with the unique statement. to assign a field as unique its like this:
    unique tablefield (tablefield). In any case i tried this statement and it worked.

    Create table quizes (
    qIDnum int(11) not null auto_increment,
    qName varchar(32) not null,
    qAuthor varchar(32) not null,
    qIDname varchar(16) not null,
    qPass varchar(32) not null,
    qMoreInfo varchar(255) not null,
    qRandQuest tinyint(4) not null default '0',
    qRandChoice tinyint(4) not null default '0',
    qTimeLimit int(11) not null default '0',
    qResultsOption tinyint(4) not null default '0',
    qWordBankUsed tinyint(4) not null default '0',
    qWordBankID int(11) not null default '0',
    qQuestions varchar(32) not null,
    qStudents varchar(32) not null,
    qListNames varchar(32) not null,
    qTypesName tinyint(4) not null default '0',
    primary key (qIDnum),
    unique qIDnum (qIDnum))

  3. #3
    Join Date
    Dec 2002
    Location
    Cape Town, South Africa
    Posts
    75
    Fireau's query works fine without the quotes. From the MySQL manual:

    Note that the rules changed starting with MySQL Version 3.23.6 when we introduced quoting of identifiers (database, table, and column names) with ``'. `"' will also work to quote identifiers if you run in ANSI mode.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •