Register FAQ Designers List Calendar Search Today's Posts Mark Forums Read

 
Go Back   Guild Inn - Gaming GFX Site > General Section > Off Topic

Notices

Off Topic Talk about anything you want in here.

Reply
 
Thread Tools Display Modes

Need some MySQL code help
Old 17-08-08, 16:35   #1
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
Need some MySQL code help

Basically I'm crap at SQL code.

Anyone here have any knowledge of writing SQL code?
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 16:52   #2
 
DustPox's Avatar
 
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
Blog Entries: 4
Send a message via AIM to DustPox Send a message via MSN to DustPox Send a message via Skype™ to DustPox
Moderate knowledge here mate =)
  Reply With Quote

Old 17-08-08, 17:02   #3
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
Ok I'd apprecriate some help.

If I was to create the following tables, would my code be appropriate?

Hotel(hotelNo, hotelName, city)
Room(roomNo, hotelNo, type, price)

CREATE TABLE Hotel (
hotelNo INTEGER,
hotelName VARCHAR(20),
City CHAR(20),

CREATE TABLE Room (
roomlNo INTEGER,
hotelNo VARCHAR(20),
type CHAR(20),
price CHAR (3)

I haven't much of a clue about SQL code. Intergers etc. See if you can make it better.
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 17:22   #4
 
DustPox's Avatar
 
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
Blog Entries: 4
Send a message via AIM to DustPox Send a message via MSN to DustPox Send a message via Skype™ to DustPox
What exactly are you trying to make or trying for it to do? i cant find an error in the code.. but well im confused as to what youre trying to do.
  Reply With Quote

Old 17-08-08, 17:25   #5
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
It's a Uni question.

'List and describe the SQL code to create the following tables. You can assume that the price of a room is always a whole number of pounds'

Hotel(hotelNo, hotelName, city)
Room(roomNo, hotelNo, type, price)


If you were to do that, what would it look like in terms of code?
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 17:27   #6
I am the egg man
 
SalMAX's Avatar
 
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
Send a message via AIM to SalMAX Send a message via MSN to SalMAX
I only know C#, Java and some C and Pascal, but assuming CHAR and INTEGER are universal - why is "price" a CHAR?
__________________
Awesome gifts






|Team Illumination|
Adrenaline - Strife - Zero - SalMAX - Socom - Ne0 - ZenemiG - Laban - NonFiction - KingPyroe - Drift - 8Bit (PIMP) - Euphoria - Darkrai
  Reply With Quote

Old 17-08-08, 17:28   #7
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
Because I don't know what CHAR and INTEGER mean. I'm clueless.
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 17:30   #8
I am the egg man
 
SalMAX's Avatar
 
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
Send a message via AIM to SalMAX Send a message via MSN to SalMAX
Its pretty straight forward. Integer is for numbers and Char is for characters.
__________________
Awesome gifts






|Team Illumination|
Adrenaline - Strife - Zero - SalMAX - Socom - Ne0 - ZenemiG - Laban - NonFiction - KingPyroe - Drift - 8Bit (PIMP) - Euphoria - Darkrai
  Reply With Quote

Old 17-08-08, 17:30   #9
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
You sir is a legend. Thanks.
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 17:32   #10
The Physics man
 
Tangster's Avatar
 
Offline
Join Date: Aug 2007
Location: England
Posts: 2,207
Blog Entries: 1
Quote:
Originally Posted by SalMAX View Post
I only know C#, Java and some C and Pascal, but assuming CHAR and INTEGER are universal - why is "price" a CHAR?
Only...

@mark, CHAR defines a character, ie letters or symbols, INTEGER is what is sounds like and defines whole numbers.

Damn Sal, you got these first.
__________________

|HappyCamper||Wuss||Baz||****||Pyro|
|****||CkChRizZ||Tangster||Shino.B||Impulse|
  Reply With Quote

Old 17-08-08, 17:36   #11
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
Thanks. Makes more sense now.
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius
  Reply With Quote

Old 17-08-08, 17:38   #12
The Physics man
 
Tangster's Avatar
 
Offline
Join Date: Aug 2007
Location: England
Posts: 2,207
Blog Entries: 1
You may want to use FLOAT instead since prices are decimals.
__________________

|HappyCamper||Wuss||Baz||****||Pyro|
|****||CkChRizZ||Tangster||Shino.B||Impulse|
  Reply With Quote

Old 17-08-08, 17:40   #13
I am the egg man
 
SalMAX's Avatar
 
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
Send a message via AIM to SalMAX Send a message via MSN to SalMAX
Quote:
Originally Posted by Tangster View Post
You may want to use FLOAT instead since prices are decimals.
'You can assume that the price of a room is always a whole number of pounds'
__________________
Awesome gifts






|Team Illumination|
Adrenaline - Strife - Zero - SalMAX - Socom - Ne0 - ZenemiG - Laban - NonFiction - KingPyroe - Drift - 8Bit (PIMP) - Euphoria - Darkrai
  Reply With Quote

Old 17-08-08, 17:44   #14
I smell great
 
Dogz's Avatar
 
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
Blog Entries: 1
For this, the price is a whole number of pounds.

Just out of interest, do I have to specify the number of characters in brackets or can I just leave that

e.g hotelName CHAR

Instead of hotelName CHAR (20)

?
__________________
Quote:
Originally Posted by FlipFX View Post
Damn, Mark is a genius

Last edited by Dogz; 17-08-08 at 17:44. Reason: Automerged Doublepost
  Reply With Quote

Old 17-08-08, 21:34   #15
 
DustPox's Avatar
 
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
Blog Entries: 4
Send a message via AIM to DustPox Send a message via MSN to DustPox Send a message via Skype™ to DustPox
Quote:
Originally Posted by Dogz View Post
For this, the price is a whole number of pounds.

Just out of interest, do I have to specify the number of characters in brackets or can I just leave that

e.g hotelName CHAR

Instead of hotelName CHAR (20)

?
Well that depends on what the max size of name is..
If you put 20 there, you max the chars to twenty.. so if u have a hotel name with more than 20 chars.. your fucked..

just leave the (20)
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump



All times are GMT. The time now is 23:03.