Solved

paradox query problem

Posted on 2008-10-22
6
261 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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