update records of the same type - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-22-2009, 04:33 PM   #1 (permalink)
Junior Member
 
Join Date: Jan 2009
Posts: 1
Default update records of the same type

My solution to the following question update 10 rows. It should update only 6 records.

Create a copy of the missions table called AM_X_442_2. For missions on this table that meet the following criteria:
1. within the 10 most recent missions
2. length of the first word of the mission code_name exceeds 7 characters

Do the following:
Change the security level to the highest security level found in missions of the same type.


UPDATE
AM_X_442_2 am
SET
am.SECURITY_LEVEL =
(
SELECT
MAX(amx.SECURITY_LEVEL)
FROM
AM_X_442_2 am
INNER JOIN
AM_X_442_2 amx
ON
am.MISSION_TYPE_ID = amx.MISSION_TYPE_ID
WHERE
am.MISSION_ID in
(
SELECT
MISSION_ID
FROM
(
SELECT
MISSION_ID
FROM
AM_X_442_2
WHERE
LENGTH (SUBSTR (CODE_NAME, INSTR(CODE_NAME, ' ') +1)) > 7
ORDER BY
MISSION_DATE DESC
)
WHERE
ROWNUM <11
)
)
WHERE am.MISSION_ID IN
(
SELECT
MISSION_ID
FROM
(
SELECT
MISSION_ID
FROM
AM_X_442_2
WHERE
LENGTH (SUBSTR (CODE_NAME, INSTR(CODE_NAME, ' ') +1)) > 7
ORDER BY
MISSION_DATE DESC
)
WHERE
ROWNUM <11
)
madara79 is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:35 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting