Author Topic: SQL help needed.  (Read 5270 times)

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
SQL help needed.
« on: October 08, 2007, 09:34:52 PM »
Heyy.. naut back here asking for assistance again. It's been almost a yr since I last asked for help lol.

Anways, anyone here good at SQL?

I need some help with a program and have to get this done in a couple days, so if anyone is up for helping please let me know asap and I will post what I'm having trouble with.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #1 on: October 08, 2007, 11:32:00 PM »
anyone know how to use isql*plus?

specifically, how to enter in data and execute it to display results. I can create a table, but try and execute it and get nothing, unless I'm doing it wrong, been following the tutorial at http://www.oracle.com/technology/obe/obe9ir2/obe-mng/isqlplus/isqlplus.htm

console (of all trades).. do you know any sql?
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: SQL help needed.
« Reply #2 on: October 08, 2007, 11:51:54 PM »
console (of all trades).. do you know any sql?

I know the basic create drop insert update select syntax...  Nothing about "isqlplus" though.  I typically send SQL to database engines from programming languages.  (Perl, Ruby, etc.)


Regards,

:dohdohdoh:
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline [BTF]Defiant!

  • Carpal Tunnel Member
  • ******
  • Posts: 1502
    • View Profile
    • Quake 2 LAN party July-August 2007
  • Rated:
Re: SQL help needed.
« Reply #3 on: October 09, 2007, 12:13:43 AM »
anyone know how to use isql*plus?

specifically, how to enter in data and execute it to display results. I can create a table, but try and execute it and get nothing, unless I'm doing it wrong, been following the tutorial at http://www.oracle.com/technology/obe/obe9ir2/obe-mng/isqlplus/isqlplus.htm

console (of all trades).. do you know any sql?

If you can create the table then you should be able to query against it.  Do you have any data in the table?  Can you screenshot a before and after?
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Next Event: http://www.quakecon.org/  Fall 2014
You missed the Quake 2 LAN party at http://athenslanparty.pbwiki.com/

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #4 on: October 09, 2007, 09:15:35 AM »
OK, I have created these tables

Code: [Select]
CREATE TABLE Student
(studentid INT,
firstname CHAR(20),
lastname CHAR(20),
grade CHAR(1),
dept CHAR(25),
DOB DATE,
fine REAL,
PRIMARY KEY(firstname);

CREATE TABLE Book
(isbn INT,
title CHAR(20),
author CHAR(20),
edition INT,
bookyear DATE)

CREATE TABLE Borrowed
(studentid INT,
isbn INT,
borrowdate DATE,
due DATE)

Then I have to create 10 tuples with data for each. After that I am to retrieve data.. but will worry about that later, for now I want to know how to make up data for the tables, any ideas?
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline reaper

  • Opulent Member
  • *
  • Posts: 2872
  • Nice night for a walk, eh? - Nice night for a walk
    • View Profile
  • Rated:
Re: SQL help needed.
« Reply #5 on: October 09, 2007, 09:18:48 AM »
General format:
create database
create tables
create fields
grant privledges

populate database
query database

I use mysql, phpmysqladmin (for a gui admin interface), and usually populate the database with user input, or a feed from a named pipe.

I don't u se iSQL, but from glancing over your link, it looks pretty similar to mysql.
« Last Edit: October 09, 2007, 09:39:02 AM by reaper »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
VaeVictus "reaper is a lying sack of shit and ragequit then had, probably slugs, come alias and beat me, wasnt even the same person playing OBVIOUSLY, accuracies basicly doubled, and strategy

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #6 on: October 09, 2007, 09:49:04 AM »
Thanks reaper.. I was looking for the INSERT cmd, wasn't sure how to input generic data to run a query.

I'm working on it now and will show my results in a little bit.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #7 on: October 11, 2007, 04:04:50 PM »
Anyone know the cmd to find out how many records there are of a specific person.

Say you want to find out how many students have the first name mike.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: SQL help needed.
« Reply #8 on: October 11, 2007, 04:20:07 PM »
Anyone know the cmd to find out how many records there are of a specific person.

Say you want to find out how many students have the first name mike.

http://www.techonthenet.com/sql/count.php

select count(*) from students where first_name like 'mike';

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #9 on: October 11, 2007, 04:52:12 PM »
I tried googlin' it with no luck..

thanks console.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #10 on: October 11, 2007, 05:28:32 PM »
Another question, say you want to find the person who has rented the most movies from the year 2000 to 2007.

Do you perform a count first, then compare it and display results?

Stuck on this one for the last half hour.. any info would be appreciated.
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: SQL help needed.
« Reply #11 on: October 11, 2007, 06:38:14 PM »
Another question, say you want to find the person who has rented the most movies from the year 2000 to 2007.

Do you perform a count first, then compare it and display results?

Depends on what your tables look like.  What sort of records keep track of movie rentals?  Is it like a row for each movie rented, with a userid and a date?

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #12 on: October 11, 2007, 06:43:09 PM »
Well its actually trying to find the highest borrowing record for a students last name for the year 2000-2007

my tables are below with some sample data.

Code: [Select]
CREATE TABLE STUDENT
(STUID INTEGER PRIMARY KEY,
FNAME CHAR(20),
LNAME CHAR(20),
GRADE CHAR(2),
DEPT CHAR(25),
DOB CHAR(10),
FINE REAL);

-- Book table
CREATE TABLE BOOK
(ISBN INTEGER PRIMARY KEY,
TITLE CHAR(30),
AUTHOR CHAR(20),
EDITION CHAR(5),
BOOKYR CHAR(4));

-- Borrowed table
CREATE TABLE BORROWED
(STUID INTEGER,
ISBN INTEGER,
BORROWDATE CHAR(10),
DUE CHAR(10)
PRIMARY KEY(STUID, ISBN, BORROWDATE));

-- Sample data for STUDENT
INSERT INTO STUDENT VALUES ('4567', 'Michael', 'Doe', 'C', 'English', '02/15/1982', '20.00')

-- Sample data for BORROWED
INSERT INTO BORROWED VALUES ('4567', '3456345798', '10/05/2007', '11/05/2007')


What do you think?
« Last Edit: October 11, 2007, 06:47:44 PM by [N]auTiCa »
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline [N]auTiCa

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
    • Extreme Online Gaming
  • Rated:
Re: SQL help needed.
« Reply #13 on: October 11, 2007, 07:00:43 PM »
Do you think this would work? I can't test any of these statements as I don't have access to a database, but the logic seems right

Code: [Select]
Select LNAME, COUNT(LNAME)
 FROM BORROWED GROUP BY LNAME, DEPT
 HAVING COUNT(LNAME)=(SELECT MAX(A.CNT)
 FROM (SELECT COUNT(LNAME) AS CNT FROM STUDENT
 GROUP BY (LNAME, DEPT)) AS A);
  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus
Clan ^K][L^  co-leader! www.clankil.com
dC member! www.monsterkill.org

Offline console

  • Brobdingnagian Member
  • ***
  • Posts: 4518
  • "Man, this is the way to travel," said my attorney
    • View Profile
    • tastyspleen.net
  • Rated:
Re: SQL help needed.
« Reply #14 on: October 11, 2007, 08:57:16 PM »
Hmm.  Not really sure.  It doesn't quite look right to me, but I don't write queries like these often, and when I do I have to consult my SQL book each time.

BTW, why don't you have access to a database?  You could install sqlite3 or mysql or postgres on your local system.  Wouldn't that work?


Regards,

quadz

  • Insightful
    Informative
    Funny
    Nice Job / Good Work
    Rock On
    Flawless Logic
    Well-Reasoned Argument and/or Conclusion
    Demonstrates Exceptional Knowlege of the Game
    Appears Not to Comprehend Game Fundamentals
    Frag of the Week
    Frag Hall of Fame
    Jump of the Week
    Jump Hall of Fame
    Best Solution
    Wins The Internet
    Whoosh! You done missed the joke thar Cletus!
    Obvious Troll Is Obvious
    DO YOU EVEN LIFT?
    DEMO OR STFU
    Offtopic
    Flamebait
    Redundant
    Factually Challenged
    Preposterously Irrational Arguments
    Blindingly Obvious Logical Fallacies
    Absurd Misconstrual of Scientific Principles or Evidence
    Amazing Conspiracy Theory Bro
    Racist Ignoramus

 

El Box de Shoutamente

Last 10 Shouts:

Costigan_Q2

November 11, 2024, 06:41:06 AM
"Stay cozy folks.

Everything is gonna be fine."

There'll be no excuses for having TDS after January 20th, there'll be no excuses AT ALL!!!
 

|iR|Focalor

November 06, 2024, 03:28:50 AM
 

RailWolf

November 05, 2024, 03:13:44 PM
Nice :)

Tom Servo

November 04, 2024, 05:05:24 PM
The Joe Rogan Experience episode 223 that dropped a couple hours ago with Musk, they're talking about Quake lol.

Costigan_Q2

November 04, 2024, 03:37:55 PM
Stay cozy folks.

Everything is gonna be fine.
 

|iR|Focalor

October 31, 2024, 08:56:37 PM

Costigan_Q2

October 17, 2024, 06:31:53 PM
Not activated your account yet?

Activate it now! join in the fun!

Tom Servo

October 11, 2024, 03:35:36 PM
HAHAHAHAHAHA
 

|iR|Focalor

October 10, 2024, 12:19:41 PM
I don't worship the devil. Jesus is Lord, friend. He died for your sins. He will forgive you if you just ask.
 

rikwad

October 09, 2024, 07:57:21 PM
Sorry, I couldn't resist my inner asshole.

Show 50 latest
Welcome, Guest. Please login or register.
November 22, 2024, 03:51:00 PM

Login with username, password and session length