| Notices |
Have you entered the 152nd GI SOTW? CLICK HERE for more information. Also, take a look at the winner of the 151st GI SOTW HERE. |
| Off Topic Talk about anything you want in here. |
 |
Need some MySQL code help |
 |
17-08-08, 16:35
|
#1
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
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
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 16:52
|
#2
|
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
|
Moderate knowledge here mate =)
|
|
|
|
17-08-08, 17:02
|
#3
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
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
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 17:22
|
#4
|
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
|
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.
|
|
|
|
17-08-08, 17:25
|
#5
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
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
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 17:27
|
#6
|
|
I am the egg man
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
|
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
|
|
|
|
17-08-08, 17:28
|
#7
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
Because I don't know what CHAR and INTEGER mean. I'm clueless.
__________________
Quote:
Originally Posted by FlipFX
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 17:30
|
#8
|
|
I am the egg man
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
|
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
|
|
|
|
17-08-08, 17:30
|
#9
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
You sir is a legend. Thanks.
__________________
Quote:
Originally Posted by FlipFX
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 17:32
|
#10
|
|
The Physics man
Offline
Join Date: Aug 2007
Location: England
Posts: 2,207
|
Quote:
Originally Posted by SalMAX
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|
|
|
|
|
17-08-08, 17:36
|
#11
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
Thanks. Makes more sense now.
__________________
Quote:
Originally Posted by FlipFX
Damn, Mark is a genius
|
|
|
|
|
17-08-08, 17:38
|
#12
|
|
The Physics man
Offline
Join Date: Aug 2007
Location: England
Posts: 2,207
|
You may want to use FLOAT instead since prices are decimals.
__________________
|HappyCamper||Wuss||Baz||****||Pyro|
|****||CkChRizZ||Tangster||Shino.B||Impulse|
|
|
|
|
17-08-08, 17:40
|
#13
|
|
I am the egg man
Offline
Join Date: May 2007
Location: Earth
Posts: 1,280
|
Quote:
Originally Posted by Tangster
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
|
|
|
|
17-08-08, 17:44
|
#14
|
|
I smell great
Offline
Join Date: Jan 2006
Location: Co.Armagh, N.I
Posts: 2,907
|
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
Damn, Mark is a genius
|
Last edited by Dogz; 17-08-08 at 17:44.
Reason: Automerged Doublepost
|
|
|
|
17-08-08, 21:34
|
#15
|
Offline
Join Date: Jul 2006
Location: De Lier, Zuid-Holland, Netherlands
Posts: 3,033
|
Quote:
Originally Posted by Dogz
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)
|
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
All times are GMT. The time now is 23:03. |
|
| | |