Solved

paradox query problem

Posted on 2008-10-22
6
258 Views
Last Modified: 2013-11-23
Hi
I am using Paradox tables.
Can somebody advise me on how to create a query in delphi using 2 tables
I have a header table and detail table ( 1 to N relationship)
The key field is Job_no which is unique in the header
I want to create a query which shows me all the records that have no header records in the details table
I what to avoid using a do while loop
Regards



0
Comment
Question by:SSSIAN
  • 4
6 Comments
 
LVL 6

Expert Comment

by:FactorB
ID: 22779724
You need a JOIN query, that will bring together one to many relational tables

Select header.*,detail.* from header inner join detail on header.job_no = detail.job_no;
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 100 total points
ID: 22783237
no you need a left join, not an inner

select d.*
from detail d
  left join header h on h.job_no = d.job_no
order by d.job_no

this will show you all the records in detail without header
and order them

select d.job_no, count(*) as amount_no_header
from detail d
  left join header h on h.job_no = d.job_no
group by d.job_no
order by d.job_no

will show how many records for each job_no that have no header

to delete all records in detail without header:
delete from details
where not job_no in (select job_no from header)

to see all headers without details
select h.*
from header h
  left join details d on h.job_no = d.job_no
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22784254
didn't the solution work ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:SSSIAN
ID: 22784429
Sorry Geert_Gruwez:
I am new to this, I thought I accepted the solution and gave you the points
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22784468
if the solution works, you should give an A
if it only works half and you have to edit the code and do research give it a B
if it doesn't work at all give comments and let the experts handle the comments

if you are totally dissatified with the experts comments and all experts have commented
give it a C

or read the help section on Asking Questions and grading on the EE
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22788518
did the solution work ?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to disable mouse scroll in a combo box field within a Delphi cxGrid 4 111
Working with hours 3 46
Firemonkey webbrowser scrollbars ? 1 29
CheckListBox usage 3 50
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now