• Best of luck to the class of 2024 for their HSC exams. You got this!
    Let us know your thoughts on the HSC exams here
  • YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page
MedVision ad

Sql (1 Viewer)

kolgf

Member
Joined
Nov 24, 2005
Messages
37
Location
sydney
Gender
Undisclosed
HSC
2006
Hope you guys are doing SQL coz i am a bit lost.

The questions ask to wirte an SQL search specification to find artists that are alive and the database has the field Dead and a couple of the artists are dead coz its states the date the died and like 7 are alive but in the field died they just have it empty for the alive aritists, how would i write this?

Select: Died, Surename
From: DB
Where: Died= "EMPTY"
Order by: surename-ASC

is that right?
 

seremify007

Junior Member
Joined
Apr 29, 2004
Messages
10,059
Location
Sydney, Australia
Gender
Male
HSC
2005
Uni Grad
2009
I think this is correct, where field names are "Surname" and "Died", and the database is called "Database".

SELECT Surname
FROM Database
WHERE Died=""
ORDER BY Surname ASC
 

kolgf

Member
Joined
Nov 24, 2005
Messages
37
Location
sydney
Gender
Undisclosed
HSC
2006
so if the field "Died" is empty- meaning the artist is still alive you write this

Where: Died="""?? or is it Died="EMPTY"
 

kolgf

Member
Joined
Nov 24, 2005
Messages
37
Location
sydney
Gender
Undisclosed
HSC
2006
hmm ok thanks. And one more question what are the similarities between a flat file database and a relational database?
 

STx

Boom Bap
Joined
Sep 5, 2004
Messages
473
Location
Sydney
Gender
Male
HSC
2006
^Theres probably more differences between them than similarities, but basically they both have fields,records and files. You probably know the differences right? which are more important.
 

seremify007

Junior Member
Joined
Apr 29, 2004
Messages
10,059
Location
Sydney, Australia
Gender
Male
HSC
2005
Uni Grad
2009
Aren't they called different things in between the two? Like schema vs. data dictionary, entity vs. record, etc...

Man.. it's been so long since I did IPT and I can barely remember it... LOL.
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
kolgf said:
Hope you guys are doing SQL coz i am a bit lost.

The questions ask to wirte an SQL search specification to find artists that are alive and the database has the field Dead and a couple of the artists are dead coz its states the date the died and like 7 are alive but in the field died they just have it empty for the alive aritists, how would i write this?

Select: Died, Surename
From: DB
Where: Died= "EMPTY"
Order by: surename-ASC

is that right?
Not quite - should be:

SELECT Surname, FirstName
FROM <TableName>
WHERE Died is NULL
ORDER BY Surname

Note:
ASC is unnecessary an not part of SQL
Empty or "" is different to NULL. NULL means nothing at all, not an empty string.
I'm assuming Surname and FirstName are attributes in the table.

HTH
Sam
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top