Results 1 to 2 of 2

Thread: mySQL help

  1. #1
    Join Date
    Jul 2005
    Location
    Huntingdon
    Posts
    11,633
    Tokens
    0

    Latest Awards:

    Default mySQL help

    Hello Habboxforum, I come back to you in an hour of desperate need.

    I'm trying to create a database in mySQL, which has 6 tables, but only 3 of them work... here is the sql...

    http://img526.imageshack.us/img526/3618/sql.png

    And here are the errors I get...


    ERROR 1007 (HY000): Can't create database 'shopping'; database exists
    Database changed
    Query OK, 0 rows affected (0.03 sec)

    ERROR 1064 (42000): 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 '(), T
    otal_Price Double, Cust_Login varchar(20), primary key(Shopping_Cart_ID), f' at
    line 1
    ERROR 1064 (42000): 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 '), Pr
    ice DOUBLE(), primary key(Shopping_Cart_ID), primary key(Item_Code), foreig' at
    line 1
    Query OK, 0 rows affected (0.02 sec)

    ERROR 1064 (42000): 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 ' Cate
    gory_Code int(5), primary key(Item_Type_Number), foreign key(Category_Code)' at
    line 1
    Query OK, 0 rows affected (0.02 sec)

    I can't figure why I'm getting errors... any help is really appreciated.






  2. #2
    Join Date
    Jun 2004
    Location
    Reading, Berkshire
    Posts
    2,260
    Tokens
    12,202
    Habbo
    :Jin:

    Latest Awards:

    Default

    Not sure what possessed you to create it as a png :S

    Okay so I am debugging your code which hasn't been made easier as I have had to use OCR software to convert it into text.

    There are quite a few basic issues here.

    Such as DATE() instead of DATE.
    Foreign Keys Referencing fields in tables which haven't been created yet.
    Fields being created without a data type (item_Type.Graphics)



    The above is your corrected code, I can't remember all the errors in it but here are the major ones that would flaw your database design.

    First of all, you can't have multiple primary keys for one table. So I assumed shopping_cart_item was meant to be a composite key.
    Secondly you must define datatypes for every field. So for item_Type.Graphics I just made it a varchar(50) as I dont really know what this field is for.

    Looking at the use of camel case (which at university level no one really uses anymore) and the sql as an image I am assuming that this is for CPT6 in AQA Computing. In which case you may need to reference this in your documentation if you want credit for it legitimately.
    Last edited by Jin; 07-12-2010 at 04:08 PM.


Posting Permissions

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