running query getting error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrityunjay11
    New Member
    • Jul 2007
    • 26

    running query getting error

    Error

    SQL query:
    [CODE=mysql]CREATE TABLE per(
    item_name varchar,
    item_number int,
    payment_status int,
    payment_amount int,
    payment_currenc y int
    );[/CODE]

    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 '
    item_number int,
    payment_status int,
    payment_amount int,
    payment_cu' at line 2
    Last edited by mwasif; Jul 28 '07, 03:13 PM. Reason: Added code tag
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Moving from Misc question. Sorry SQL folks, its your problem now :)

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, mrityunjay11.

      When you create a varchar column, you must specify a length:

      [code=mysql]
      CREATE TABLE
      `per `
      (
      `item_name`
      varchar(50),
      `item_number`
      int,
      `payment_status `
      int,
      `payment_amount `
      int,
      `payment_curren cy`
      int
      )
      [/code]

      You also may want to consider changing some of your ints to tinyints to save space.

      For example, if there are only 5 possible values for `payment_curren cy`, then you only need one bit to save that data (tinyint). Using int, however, uses three bits instead of one, which is two bits more than you need. If your table had 20,000 rows, that means an extra 40,000 bits -> 5KB of wasted space.

      Here's a suggestion for optimizing the table:
      [code=mysql]
      CREATE TABLE
      `per`
      (
      `item_name`
      VARCHAR(50)
      NOT NULL,
      `item_number`
      INT(10)
      UNSIGNED
      NOT NULL
      UNIQUE,
      `payment_status `
      ENUM
      (
      'paid',
      'not paid'
      )
      NOT NULL
      DEFAULT 'not paid',
      `payment_amount `
      FLOAT(8,2)
      UNSIGNED
      NOT NULL
      DEFAULT 0.00,
      `payment_curren cy`
      TINYINT(2)
      UNSIGNED,
      NOT NULL
      DEFAULT 0
      )
      [/code]

      For more information, check out this page.

      Good luck with your project, and if you ever need anything, post back anytime :)

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        Kindly use CODE tags when posting source code. See the Posting Guidelines.

        Comment

        • mrityunjay11
          New Member
          • Jul 2007
          • 26

          #5
          thank u my problewm is solved

          Comment

          Working...