2 Queries into 1 Table...How?

2 Queries into 1 Table...How?

Post by Paul LaForg » Thu, 09 Apr 1998 04:00:00



Query  1 Fields:
FirstName
LastName
Birthdate

Query 2 Fields:
SpouseName
LastName
SpouseBirthdate

Table Fields:
FirstName
LastName
Birthdate

I am trying to create a report using CR based on the table.  However, I need
to append the data of each query into the corresponding field(s) of the
table.  I'm pretty sure this is a SQL issue but I'm having no luck so
far....

Any suggestions/code appreciated...

PL

 
 
 

2 Queries into 1 Table...How?

Post by Tom Schif » Thu, 09 Apr 1998 04:00:00


You don't mention your version of Crystal or your back end.
With Cr 5.0 and above and a SQL Server backend I would create a stored
proceedure that would:
Create a teporary table  with a structure
    FirstName
    LastName
    Birthdate
   SpouseFirstName
   SpouseLastName
   SpouseBirthdate
Select FirstName, LastName, BirthDate
Into #tempNames
From tblNames
Where <<Conditon Clause>>

Update the Spouse fields

Select * from #tempNames
Drop table #tempNames

 
 
 

2 Queries into 1 Table...How?

Post by Brian & Tara Don » Thu, 09 Apr 1998 04:00:00



> Query  1 Fields:
> FirstName
> LastName
> Birthdate

> Query 2 Fields:
> SpouseName
> LastName
> SpouseBirthdate

> Table Fields:
> FirstName
> LastName
> Birthdate

> I am trying to create a report using CR based on the table.  However, I need
> to append the data of each query into the corresponding field(s) of the
> table.  I'm pretty sure this is a SQL issue but I'm having no luck so
> far....

> Any suggestions/code appreciated...

> PL


Hi Paul,

What you would need to do is create a Union of the two queries.

--
Sincerely,
Brian Dong

To reply, remove nospam from the address.

 
 
 

2 Queries into 1 Table...How?

Post by Joel Maxso » Fri, 10 Apr 1998 04:00:00


Paul,
    Create a 3rd query that includes all the fields that you want to appear
on the report.

Joel



> Query  1 Fields:
> FirstName
> LastName
> Birthdate

> Query 2 Fields:
> SpouseName
> LastName
> SpouseBirthdate

> Table Fields:
> FirstName
> LastName
> Birthdate

> I am trying to create a report using CR based on the table.  However, I
need
> to append the data of each query into the corresponding field(s) of the
> table.  I'm pretty sure this is a SQL issue but I'm having no luck so
> far....

> Any suggestions/code appreciated...

> PL


 
 
 

1. Query using UDF joined to a sub query vs Temp Table to sub Query

I have a simple query question.  Currently I have a query that joins a UDF that returns a table to a sub query of a number of secondary tables.  This query seems to run forever, but if I dump the results of the udf into a temp table and use joined to the sub query the results are as expected.  Can anyone shed some light onto why?  Also is it possible to use the UDF in this manner with possible join hints to get the query return time I'm looking for?

2. Problem: How to implement a scrollbar INSIDE a DBGrid cell ???

3. Executing a Query on a Table or Query

4. OCI programming - do I need terminating ;?

5. Query, opening a query with a table missing

6. EXEC( ) problem

7. pdox 5.0 want to convert queries using .dbf table to .db without rebuilding queries

8. Database save to file

9. Query between 2 tables, where 2nd table foreign key is null

10. Get query that creates tables, from tables

11. Database table and query into html table

12. Query Optimizer ?-small tables/table scan

13. Queries and Private Tables - Private Table not found