Off Topic
Are you a QOTWer? Do you want to start a thread that isn't a direct answer to the current QOTW? Then this place, gentle poster, is your friend.
( , Sun 1 Apr 2001, 1:00)
Are you a QOTWer? Do you want to start a thread that isn't a direct answer to the current QOTW? Then this place, gentle poster, is your friend.
( , Sun 1 Apr 2001, 1:00)
« Go Back | See The Full Thread
REPLYING TO WILL DOWN HERE.
You can, but you would do that outside of the database level and into the program side of things. There are better sollutions to what I come up with, but this would be easier to follow.
Like how b3ta works, every post has a parent, even the first post in a thread which would be something like '0' as the secondry 'parent' key.
// Selecting what columns we would like to use. The bit before a dot is the table name... bare with me on that 'till you finish reading. the bit after the 'as' is what we're tempoary naming the columns
SELECT child.UserID child.name AS Name, child.colour AS Colour, mother.name AS MotherName, mother.colour AS MotherColour, father.name AS FatherName , father.colour as FatherColour
// We're picking the table we want it from, which is 'sheep' and calling it child.
FROM sheep as child
//now we are 'joining' another table, the sheep one, and calling it mother. We are joining it on the child one's motherid being = to the mother's one sheepid
INNER JOIN sheep AS mother ON child.MotherID = mother.SheepID
//Exactly the same thing with the father
INNER JOIN sheep AS father ON child.FatherID = father.SheepID
With this, it'll give me the current one's id, name and colour. And then the name and colour of both parents. We can use looping of this to get an entire family tree that's easily useable. Stuff in capitals in that are 'things' for lack of an easier word, that make up the language of SQL.
( , Fri 4 May 2012, 22:32, 1 reply, 12 years ago)
You can, but you would do that outside of the database level and into the program side of things. There are better sollutions to what I come up with, but this would be easier to follow.
Like how b3ta works, every post has a parent, even the first post in a thread which would be something like '0' as the secondry 'parent' key.
// Selecting what columns we would like to use. The bit before a dot is the table name... bare with me on that 'till you finish reading. the bit after the 'as' is what we're tempoary naming the columns
SELECT child.UserID child.name AS Name, child.colour AS Colour, mother.name AS MotherName, mother.colour AS MotherColour, father.name AS FatherName , father.colour as FatherColour
// We're picking the table we want it from, which is 'sheep' and calling it child.
FROM sheep as child
//now we are 'joining' another table, the sheep one, and calling it mother. We are joining it on the child one's motherid being = to the mother's one sheepid
INNER JOIN sheep AS mother ON child.MotherID = mother.SheepID
//Exactly the same thing with the father
INNER JOIN sheep AS father ON child.FatherID = father.SheepID
With this, it'll give me the current one's id, name and colour. And then the name and colour of both parents. We can use looping of this to get an entire family tree that's easily useable. Stuff in capitals in that are 'things' for lack of an easier word, that make up the language of SQL.
( , Fri 4 May 2012, 22:32, 1 reply, 12 years ago)
Sweet
I don't really know much about a language called Ruby, aside that if I was starting to code from the begining of my career, its what I would be doing, but this is really cool: tryruby.org/levels/1/challenges/0
( , Fri 4 May 2012, 23:04, Reply)
I don't really know much about a language called Ruby, aside that if I was starting to code from the begining of my career, its what I would be doing, but this is really cool: tryruby.org/levels/1/challenges/0
( , Fri 4 May 2012, 23:04, Reply)
« Go Back | See The Full Thread