473,799 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compute and update query

3 New Member
--
-- 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','61 5','844-2573'),
(1002,'Dunne',' Leona','K','713 ','894-1238'),
(1003,'Smith',' Kathy','W','615 ','894-2285'),
(1004,'Olowski' ,'Paul','F','61 5','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','71 3','382-7185'),
(1010,'Smith',' Olette','K','61 5','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,'Ram blin Tulip','3.50',' 0.25'),
('R2345',2,'Onc e Upon a Midnight Breezy','4.0000 ','0.25'),
('S4567',3,'Tul ips and Threelips','3.0 0','0.25'),
('W1234',5,'Bri ght 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_cod e)
) 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_nu m)
) 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_c hg_day decimal(8,2) default '0.00',
rentline_date_o ut datetime default NULL,
rentline_date_d ue datetime default NULL,
rentline_date_i n datetime default NULL,
rentline_days_l ate int(11) default '0',
rentline_overdu e_chg decimal(8,2) default '0.00',
PRIMARY KEY (rent_num,rentl ine_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_l ate 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 1442
tlhintoq
3,525 Recognized Expert Specialist
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
7055
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 that same field. In some instances, it will have to go back a few records before it finds a value that is not null. Can this be done? Thanks Bill
5
13224
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 report vba instead of making different queries. Here's my query sql: UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
10
3286
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 wouldn't work (nothing changed): UPDATE tblManuals SET tblManuals.PARTNUM = Trim(); Would someone please tell me how to do an update query that will trim the spaces?
5
4705
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 the record that is selected in the list box? The data updates right, but I can't get the update query to do anything but update all of the records. Thanks, Andrew
4
11342
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 AddressDescription of Entity 456 = AddressDescription of Entity_ID 123 Address1 of Entity 456 = Address1 of Entity_ID 123 City of Entity 456 = City of Entity_ID 123
7
3541
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" Transactions = name of the table I want to update balance = name of the field i want to update daily balance= name of the query result that I want to move to the table
2
5073
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 underlying subquery to this Update query involves a MAX function on a date field, which is then used in the DLookup statement. Any help appreciated. Thanks Richard
3
2181
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 best but am also looking at the easiest for an end user to run. The list of items is over 7000 Example: update imitmidx_sql set activity_cd = 'O', activity_dt = '20060601', prod_cat = 'OBS' where item_no = '001-LBK' update imitmidx_sql set...
5
3002
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 Thanks for help.
1
3146
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 numbering doesn't start always, running more times the update query, from the same starting parameter assigned (1000000000). It seems to me that it takes memory last number calculated and running prox update it starts from last table row updated. I need...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.