473,386 Members | 1,842 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,386 software developers and data experts.

Help with a Subquery

Hi, uber newbie here trying to complete a task I have been given and having no end of trouble. Here's the situation:

I have a billing table and a customers table. What I need to do is to select the rows in the billing table where the bill date is at least 14 days overdue and in an unpaid status. no problem there. Where I am encountering the problem is in marking the customer record inactive for any rows that match that query. I am trying to use a subquery, but the only way I have been able to get it to work at all ends up marking all customer rows inactive, rather than just the one that should be returned. My query is as follows:

UPDATE CUSTOMER SET CUSTOMER.C_DEL = CURRENT_DATE WHERE EXISTS (SELECT * FROM BILLING WHERE B_PAID = 'NO' AND (B_DUEDATE +15) < CURRENT_DATE)

Can anyone shed some light on what I am missing?

Thanks in advance,
Shiloh
Jun 9 '07 #1
2 1003
debasisdas
8,127 Expert 4TB
Hi
MydKnight
Welcome to TSDN.

You have reached the right place for knowledge shairing.

Here you will find a vast resource of related topics and code.

Feel free to post more doubts/questions in the forum.

But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.

It will help Experts in the forum in solving/underestanding your problem in a better way.

Please follow the posting guidelines in every new post/reply.
Jun 11 '07 #2
debasisdas
8,127 Expert 4TB
The EXISTS condition is considered "to be met" if the subquery returns at least one row.
Jun 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Don | last post by:
Hi, I am moving from Sybase to Oracle and I used to be able to do update statement like this in Sybase: UPDATE TABLE1 SET T1.field1 = T2.field2 FROM TABLE1 T1, TABLE2 T2 WHERE T1.field2...
0
by: leegold2 | last post by:
I tried what's below, seemed OK, so I replaced an "IN" for the "=" in the subquery below because of the subquery's error message. I thought w/"IN" I'd get three (3) records returned as expected....
17
by: the other john | last post by:
This should be fairly basic but I can't think of how to do this and I'm running out of time! I am developing a picture gallery and I can't figure out how to select "one" picture from each...
2
by: Rob Kopp | last post by:
I have a query that I need a hand on. I am trying to add togther some fiends based on values of another. What I would like to add a billing total by saying more or less the following: SELECT...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
15
by: MLH | last post by:
Mr Leigh Purvis gave me a very clever piece of SQL to accomplish what is probably an uncommon objective. In it, he uses the EXISTS operator. I can find no documentation on it in A97 HELP. I would...
6
by: phillip.s.powell | last post by:
update student s set school_year_id = (select distinct s.id from school_year s, interns i where lower(s.school_year_name) = lower(i.enrollment_year)and s.unique_key = i.unique_key group by s.id);...
0
by: Laura-Jayne | last post by:
Join Date: May 2006 Posts: 6 Help - SQL Query Anaylzer -------------------------------------------------------------------------------- Hi I am using the following code to give me...
22
by: pbd22 | last post by:
hi. I am having probelms with an update statement. every time i run it, "every" row updates, not just the one(s) intended. so, here is what i have. i have tried this with both AND and OR and...
1
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.