473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

compute and update query

--
-- Table structure for table borrower
--
DROP TABLE IF EXISTS borrower;
CREATE TABLE borrower (
brw_num int(11) NOT NULL default '0',
brw_lname varchar(15) default NULL,
brw_fname varchar(15) default NULL,
brw_initial varchar(1) default NULL,
brw_areacode varchar(3) default NULL,
brw_phone varchar(8) default NULL,
PRIMARY KEY (brw_num)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table borrower
--
INSERT INTO borrower VALUES
(1001,'Ramas','Alfred','A','615','844-2573'),
(1002,'Dunne','Leona','K','713','894-1238'),
(1003,'Smith','Kathy','W','615','894-2285'),
(1004,'Olowski','Paul','F','615','894-2180'),
(1005,'Orlando','Myron',NULL,'615','222-1672'),
(1006,'Brian','Amy','B','713','442-3381'),
(1007,'Brown','James','G','615','297-1228'),
(1008,'Williams','George',NULL,'615','290-2556'),
(1009,'Farriss','Anne','G','713','382-7185'),
(1010,'Smith','Olette','K','615','297-3809');


--
-- Table structure for table movie
--
DROP TABLE IF EXISTS movie;
CREATE TABLE movie (
movie_code varchar(10) NOT NULL,
movie_copies int(11) default '0',
movie_name varchar(50) default NULL,
movie_charge decimal(8,2) default '0.00',
movie_late_chg_day decimal(8,2) default '0.00',
PRIMARY KEY (movie_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table movie
--
INSERT INTO movie VALUES
('M3456',3,'Ramblin Tulip','3.50','0.25'),
('R2345',2,'Once Upon a Midnight Breezy','4.0000','0.25'),
('S4567',3,'Tulips and Threelips','3.00','0.25'),
('W1234',5,'Bright Stars and Doodle Berries','4.00','0.50');

--
-- Table structure for table copy
--
DROP TABLE IF EXISTS copy;
CREATE TABLE copy (
copy_code varchar(10) NOT NULL,
copy_num int(11) default '0' ,
movie_code varchar(10) default NULL,
PRIMARY KEY (copy_code),
FOREIGN KEY (movie_code) REFERENCES movie(movie_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table copy
--
INSERT INTO copy VALUES
('M3456-1',1,'M3456'),('M3456-2',2,'M3456'),('M3456-3',3,'M3456'),
('R2345-1',1,'R2345'),('R2345-2',2,'R2345'),('S4567-1',1,'S4567'),
('S4567-2',2,'S4567'),('S4567-3',3,'S4567'),('W1234-1',1,'W1234'),
('W1234-2',2,'W1234'),('W1234-3',3,'W1234'),('W1234-4',4,'W1234'),
('W1234-5',5,'W1234');


--
-- Table structure for table rental
--

DROP TABLE IF EXISTS rental;
CREATE TABLE rental (
rent_num int(11) NOT NULL auto_increment,
brw_num int(11) default '0',
rent_charge decimal(8,2) default '0.00',
rent_date datetime default NULL,
PRIMARY KEY (rent_num),
FOREIGN KEY (brw_num) REFERENCES borrower(brw_num)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table rental
--
INSERT INTO rental VALUES
(1,1002,'7.50','2004-03-15 00:00:00'),
(2,1003,'4.00','2004-03-15 00:00:00'),
(3,1001,'4.00','2004-03-15 00:00:00'),
(4,1004,'4.00','2004-03-15 00:00:00'),
(5,1004,'4.00','2004-03-16 00:00:00'),
(6,1001,'7.00','2004-03-16 00:00:00'),
(7,1003,'4.00','2004-03-16 00:00:00'),
(8,1002,'4.00','2004-03-17 00:00:00'),
(9,1001,'4.00','2004-03-17 00:00:00'),
(10,1004,'4.00','2004-03-17 00:00:00'),
(11,1002,'4.00','2004-03-18 00:00:00'),
(12,1003,'3.50','2004-03-18 00:00:00'),
(13,1001,'4.00','2004-03-18 00:00:00'),
(14,1004,'11.00','2004-03-18 00:00:00'),
(15,1004,'4.00','2004-03-19 00:00:00');


--
-- Table structure for table rent_line
--

DROP TABLE IF EXISTS rent_line;
CREATE TABLE rent_line (
rent_num int(11) NOT NULL default '0',
rentline_num int(11) NOT NULL default '0',
copy_code varchar(10) default NULL,
rentline_charge decimal(8,2) default '0.00',
rentline_late_chg_day decimal(8,2) default '0.00',
rentline_date_out datetime default NULL,
rentline_date_due datetime default NULL,
rentline_date_in datetime default NULL,
rentline_days_late int(11) default '0',
rentline_overdue_chg decimal(8,2) default '0.00',
PRIMARY KEY (rent_num,rentline_num),
FOREIGN KEY (copy_code) REFERENCES copy(copy_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table rent_line
--
INSERT INTO rent_line VALUES
(1,1,'M3456-3','3.50','0.25','2004-03-15 00:00:00','2004-03-17 00:00:00','2004-03-17 00:00:00',0,'0.00'),
(1,2,'W1234-2','4.00','0.50','2004-03-15 00:00:00','2004-03-17 00:00:00','2004-03-17 00:00:00',0,'0.00'),
(2,1,'M3456-2','3.50','0.25','2004-03-15 00:00:00','2004-03-17 00:00:00','2004-03-17 00:00:00',0,'0.00'),
(3,1,'R2345-1','4.00','0.25','2004-03-15 00:00:00','2004-03-17 00:00:00',NULL,0,'0.00'),
(4,1,'R2345-2','4.00','0.25','2004-03-15 00:00:00','2004-03-17 00:00:00','2004-03-17 00:00:00',0,'0.00'),
(5,1,'W1234-1','4.00','0.50','2004-03-16 00:00:00','2004-03-18 00:00:00','2004-03-18 00:00:00',0,'0.00'),
(6,1,'S4567-2','3.00','0.25','2004-03-16 00:00:00','2004-03-18 00:00:00',NULL,0,'0.00'),
(6,2,'W1234-4','4.00','0.50','2004-03-16 00:00:00','2004-03-18 00:00:00','2004-03-18 00:00:00',0,'0.00'),
(7,1,'W1234-5','4.00','0.50','2004-03-16 00:00:00','2004-03-18 00:00:00','2004-03-18 00:00:00',0,'0.00'),
(8,1,'R2345-1','4.00','0.25','2004-03-17 00:00:00','2004-03-19 00:00:00','2004-03-19 00:00:00',0,'0.00'),
(9,1,'W1234-1','4.00','0.50','2004-03-17 00:00:00','2004-03-19 00:00:00','2004-03-19 00:00:00',0,'0.00'),
(10,1,'R2345-2','4.00','0.25','2004-03-17 00:00:00','2004-03-19 00:00:00','2004-03-19 00:00:00',0,'0.00'),
(11,1,'W1234-2','4.00','0.50','2004-03-18 00:00:00','2004-03-20 00:00:00',NULL,0,'0.00'),
(12,1,'M3456-2','3.50','0.25','2004-03-18 00:00:00','2004-03-20 00:00:00',NULL,0,'0.00'),
(13,1,'W1234-3','4.00','0.50','2004-03-18 00:00:00','2004-03-20 00:00:00','2004-03-22 00:00:00',2,'1.00'),
(14,1,'S4567-2','3.00','0.25','2004-03-18 00:00:00','2004-03-20 00:00:00','2004-03-21 00:00:00',1,'0.25'),
(14,2,'W1234-4','4.00','0.50','2004-03-18 00:00:00','2004-03-20 00:00:00',NULL,0,'0.00'),
(14,3,'R2345-2','4.00','0.25','2004-03-18 00:00:00','2004-03-20 00:00:00','2004-03-22 00:00:00',2,'0.50'),
(15,1,'W1234-2','4.00','0.50','2004-03-19 00:00:00','2004-03-21 00:00:00','2004-03-22 00:00:00',1,'0.50');

how can i create a query to compute and update the number of days a movie has been overdue in the rental_line table.[ Hint: use an UPDATE query to update the rentline_days_late column. You can use the date out and date in columns to do this, and you should not compute the overdue days for movies that have been rented out but not yert returned!]
May 18 '10 #1
1 1427
tlhintoq
3,525 Expert 2GB
Bytes has a policy regarding assisting students with their homework.

The short version is that the volunteers here can't help you with schoolwork.
A) We don't know what material you have and have not learned in class.
B) We don't know the guidelines you must follow.
C) In the long run giving you the answers actually short changes your education.

Hint 1: Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.
Hint 2: Your text book
Hint 3: Your instructor
Hint 4: Posting guidelines regarding homework assignments.

TIP: Read through the MSDN Library about each new control/method/area you are learning.
May 18 '10 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bill Clark | last post by:
I have about 20,000 records pulled from Excel that I need to update. What I need to do is run an update query that bascially says: If a field is null, update it with the previous record value of...
5
by: Don Seckler | last post by:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the...
10
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This...
5
by: Andrew | last post by:
I've got a list box that selects a record on a subform, and in that subform are a few text fiels and a button that runs an update query. How do I have the update query button run and only update...
4
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET...
7
by: Mark Carlyle via AccessMonster.com | last post by:
I have this update query that I am trying to run. I know the syntax is messed up but do not know how to correct it. Select 'UPDATE', Transactions,'Set = where = ' From "Get Daily Balances" ...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
3
by: rdraider | last post by:
Hi all, Any thoughts on the best way to run an update query to update a specific list of records where all records get updated to same thing. I would think a temp table to hold the list would be...
5
by: colleen1980 | last post by:
Hi: In my table there is a field of type checkbox. I create a button on my form and wants to deselect all the checkboxes in that field (PrintQueue). Table: Research_New PrintQueue Format Yes/No...
1
by: giovannino | last post by:
Dear all, I did a query which update a sequence number (column NR_SEQUENZA) in a table using a nice code (from Trevor !). 1) Given that I'm not a programmer I can't understand why...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.