Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    Oct 2007
    Posts
    241
    Member #
    15910
    Hi,
    I was trying to create a table (I already created the database) using mysql query and I just pasted the code below from a tutorial just to see what is going to happen:

    CREATE TABLE Member (
    login VARCHAR(20) NOT NULL,
    createdate DATE NOT NULL),
    PRIMARY KEY(login) )

    I got an error message like this:

    MySQL said:
    #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 '
    PRIMARY KEY(login) )' at line 3

    Can somebody help? I was using the SQL query box in my hosting account's mysql databases section.

  2.  

  3. #2
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    You've already closed the table definition by the time you get to the primary key statement. You'll want this:

    CREATE TABLE Member (
    login VARCHAR(20) NOT NULL,
    createdate DATE NOT NULL,
    PRIMARY KEY(login) )

    Alternately, you can declare login as a primary key in the column definition (this is usually what I do):

    CREATE TABLE Member (
    login VARCHAR(20) NOT NULL primary key,
    createdate DATE NOT NULL)

  4. #3
    Senior Member
    Join Date
    Oct 2007
    Posts
    241
    Member #
    15910
    Great, it worked. Thanks. One more thing, is there any significance of using capital letters at commands? or wherever we use capital or small case letter does not matter in any way?

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    It's common style to use all caps for SQL keywords and lowercase or camelcase for columns, tables, views, etc.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com