Google Answers Logo
View Question
 
Q: Need a MySQL 'create table' string ( Answered 4 out of 5 stars,   2 Comments )
Question  
Subject: Need a MySQL 'create table' string
Category: Computers > Programming
Asked by: rservice-ga
List Price: $20.00
Posted: 07 Dec 2005 13:16 PST
Expires: 06 Jan 2006 13:16 PST
Question ID: 602788
I need a MySQL query to create a table with the following columns
(character count  should be 50 unless otherwise indicated in
parentheses):

PodcastName
Category
Province (2)
Website
Email
Description
Keywords
City
DateAdded
Rating (1)  --- will be a number between 1 and 5
XML-URL
ProducerName
HostName
Answer  
Subject: Re: Need a MySQL 'create table' string
Answered By: lotd-ga on 07 Dec 2005 13:37 PST
Rated:4 out of 5 stars
 
Hi rservice,

Please find the create table statement below. Replace "Tablename" with
your preferred name for the table.

CREATE TABLE Tablename
(
PodcastName varchar(50),
Category varchar(50),
Province varchar(2),
Website varchar(50),
Email varchar(50),
Description varchar(50),
Keywords varchar(50),
City varchar(50),
DateAdded varchar(50),
Rating tinyint,
XML-URL varchar(50),
ProducerName varchar(50),
HostName varchar(50)
);

If you require any further clarification, please do not hesitate to ask.

Regards,
lotd

Request for Answer Clarification by rservice-ga on 07 Dec 2005 13:41 PST
Thanks - I'm getting this error message:

#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 '-URL varchar(50),
ProducerName varchar(50),
HostName varchar( 

I'm using the Query function in MyPHPAdmin.

Request for Answer Clarification by rservice-ga on 07 Dec 2005 13:56 PST
Never mind, found the bug. It didn't like the  -  in XML-URL.  I
removed it and it worked fine. Thanks!

Clarification of Answer by lotd-ga on 07 Dec 2005 14:07 PST
Hi rservice,

My apologies, I failed to notice one of your column names has a special character.

To overcome this problem the column name has to be quoted. Please use
the following statement and let me know if it works ok.

CREATE TABLE Tablename
(
PodcastName varchar(50),
Category varchar(50),
Province varchar(2),
Website varchar(50),
Email varchar(50),
Description varchar(50),
Keywords varchar(50),
City varchar(50),
DateAdded varchar(50),
Rating tinyint,
`XML-URL` varchar(50),
ProducerName varchar(50),
HostName varchar(50)
);

Regards,
lotd
rservice-ga rated this answer:4 out of 5 stars

Comments  
Subject: Re: Need a MySQL 'create table' string
From: bridgetsbuddy-ga on 07 Dec 2005 13:49 PST
 
May I humbly suggest that an optional definition of the table is as follows:

CREATE TABLE podcast (
podcast_id int(11) unsigned NOT NULL auto_increment,
podcast_name varchar(50) NOT NULL default '',
category varchar(50) NOT NULL default '',
province char(2) NOT NULL default '',
website varchar(50) NOT NULL default '',
email varchar(50) NOT NULL default '',
description varchar(50) NOT NULL default '',
keywords varchar(50) NOT NULL default '',
city varchar(50) NOT NULL default '',
date_added date NOT NULL default '0000-00-00',
rating tinyint(1) unsigned NOT NULL default 0,
xml_url varchar(50) NOT NULL default '',
producer_name varchar(50) NOT NULL default '',
host_name varchar(50) NOT NULL default '',
PRIMARY KEY (podcast_id)
);

and that with more detail some relationships can be built out;
May I also suggest that having a default size of 50 for strings is not
the most efficient use of space;
Subject: Re: Need a MySQL 'create table' string
From: aristoi-ga on 07 Dec 2005 13:53 PST
 
rservice-ga, you can fix the error by changing that dash to an
underscore in XML-URL.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy