Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: Is Outputting two tables with Join my best option?

$
0
0

rickaclark54,

 

The short answer is yes, a Join would be the preferred way to handle this.  Also, mySQL would definitely be a step up from using Microsoft Access.  Most developers would recommend not using Microsoft Access in a production system.

 

That being said, there are a number of problems with the third query which result in the error you are seeing, as well as other errors that will likely be thrown once that is resolved:

 

  1. You are attempting a query-of-query statement.  You can't do that against an actual database.  You need to change the CFQUERY tag from this:
    <CFQUERY NAME="getDetails" datasource="#application.database#"> to this:
    <CFQUERY NAME="getDetails" dbtype="query">.
  2. You are blindly unioning together two tables that likely have completely different structures by using SELECT *.  Unions can only be used when the SELECT statements select a matching set of columns in two tables (by matching I mean same number of columns and same data types).  And UNIONS essentially append the results from the second query to the results from the first query, which I don't think you want.

I would definitely try a single query using an appropriate JOIN clause.  I would also suggest selecting only the columns you need from either table rather than using SELECT *, especially if both tables have any columns with the same name.

 

HTH,

-Carl V.


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>