Query of queries problem.

Hello

I want to access the data from two different data sources, without a common key. For example:

Table1:

Select stmts

Table 2

Select stmts

Table12 <! - joining two tables to access the data from the tables - >

Select table1.x, table2.y

where? = ?????

How to deal with these features?

Thanks in advance,

Vijay.

PPS

If you try to join two tables in two databases may not (and may not be made to) see each other.  You can basically do the same thing with the query in the query.  You would simply query the appropriate data in each database.  Then, you must use a query of query block ... , replacing variables with the data in the other table in them for table names in SQL.

Just be awary query of query has a rather limited Assembly capability and cannot do the inner joins.

Tags: ColdFusion

Similar Questions

  • Zoom on query of queries

    I use stand-alone ColdFusion 9

    I'm still a little new to this, but I found code of exploration down that fits my needs for my application. It uses a query of queries which, to a certain extent, I understand. My problem is when I want to take down a few steps further. The first query lists products that are associated with related by-products. By clicking on a product, it will display a list of related subcategories. I would then each by-product a link to a detail page, but I don't know if my link of by-product code is correct, and I'm not sure what the page detail request should look like to show this specific detail of by-product. Here is the code I have so far:

    The exploration down product page:

    < cfquery name = "GetDetail" datasource = cachedwithin "mm_instance" = "1" >
    SELECT products.productID, products.product, instance.instances
    OF products, Instance, ProductInstance
    WHERE products. ProductID = ProductInstance.productID AND ProductInstance.instanceID = instance.instanceID
    < / cfquery >
    < cfquery dbtype = "query" name = "zoom on" >
    SELECT DISTINCT productID, product
    OF GetDetail
    ORDER BY product
    < / cfquery >

    < cfoutput query = "Zoom on" >
    < table width = "100%" id = "box" >
    < b >
    < td valign = "top" width = "510" id = "prodname" > < a href = "Inst_List.cfm? ProductID = #DrillDown.ProductID # "> #DrillDown.product # < br > < /a > < table >"
    < /tr >
    < /table >
    < / cfoutput >

    By-product (or Instance) exploration to the bottom of the Page:

    < cfquery name = "GetDetail" datasource = cachedwithin "mm_instance" = "1" >
    SELECT products.productID, products.product, instance.instances
    OF products, Instance, ProductInstance
    WHERE products. ProductID = ProductInstance.productID AND ProductInstance.instanceID = instance.instanceID
    < / cfquery >
    < cfquery dbtype = "query" name = "zoom on" >
    SELECT instances, productID
    OF GetDetail
    WHERE GetDetail.productID = #url.productID #.
    ORDER BY product
    < / cfquery >

    < cfoutput query = "Zoom on" >
    < table width = "100%" id = "box" >
    < b >
    < td valign = "top" width = "510" id = "prodname" > < a href = "Inst_Detail.cfm? productID = #DrillDown.productID #" > #DrillDown.instances # < /a > < table >
    < /tr >
    < /table >
    < / cfoutput >

    By-product of detail page:

    Don't know what this query should look like

    Thank you!

    You are using too many requests.  On the first page, just select a different set of products and their identification card, unless you need the value of the instance for something else.  On your exploration down the page, you must select all products again.  Simply select one of the variable url.

  • query of queries case-sensitive

    Hello

    I have a question regarding this issue.  I am pulling data from an xml file and dump these data in the query of queries and their output.  The problem is when I try to order the CSA query, the stem will be high and fewer will be on the bottom.  Is it possible to sort them before the dump in query data?  Or ways around this?

    Thank you.

    functions upper() and lower() SQL function in q.

  • Can't find answer to a query of queries error

    Not only I saw this forum, but also google this problem, but the unfortunnately I have no chance to find the answer.

    I wrote this simple query:

    < cfquery name="test" dbtype="query">

    Select The SSN, date of birth de myquery where SSN <> '' OR Date of birth <>"

    < / cfquery >

    and I got this error:

    Error running query of queries.

    Exception of comparison when running <>.
    Unsupported Type comparison Exception: the <>operator does not support comparison between the following types:
    Type of expression left side = 'DOUBLE '.
    Expression type side right hand = "STRING".

    I tried the following and has not worked either, still got the same error.

    < cfquery name ="test" dbtype ="query">

    Select The SSN, date of birth de myquery

    NSS <> < cfqueryparam cfsqltype ="CF_SQL_VARCHAR" Value =""/ >

    OR Date of birth <> < cfqueryparam cfsqltype ="CF_SQL_VARCHAR" Value =""/ > < / cfquery >

    Ever met someone the same problem and know how to solve it?

    Select SSN, date of birth of myquery where cast (SSN to the varchar type) <> " OR cast (date of birth as varchar) <> "

  • Query of queries: error when you try to fake Left Outer Join

    Hello

    I'm trying to reproduce a left outer join, combining two query of queries using a method I find here

    However, I get an error message...

    Here is the code I use...

    < cfquery dbtype = "query" name = "qry" >
    SELECT *.
    OF returnQry, returnQry2
    WHERE returnQry.mediumImage = returnQry2.mediumImage
    ORDER BY returnQry.name
    < / cfquery >

    < name cfquery = "returnQry3", dbtype = "#application.mx #" >
    SELECT *.
    OF trackmeanings t
    < / cfquery >

    < cfquery dbtype = "query" name = "endQry" >
    SELECT name, nameRcd, mediumImage, comments COUNT (sMessage)
    OF qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack

    UNION

    SELECT name, nameRcd, mediumImage, comments COUNT (sMessage)
    OF qry, returnQry3
    WHERE #qry.name # NOT IN (#QuotedValueList (returnQry3.sNameTrack) #)
    GROUP BY name, nameRcd, mediumImage
    < / cfquery >

    When I try to use the query output in a page, I get the error message "incorrect conditional expression, waiting for an a [as |]» null | between | in | "comparison condition.

    Anyone have any ideas?

    Thank you very much

    The items in the list should be cited.  Since you are using quotedvaluelist, it's weird that they aren't.  However, if you use cfqueryparam, list = Yes, you should have better luck.  Among other things, it will protect you against the apostrophe in names.

  • Error running query of queries

    Hello

    I am in the process of updating my site in CF5 to CF9 and I get a "query of query error" on the following code each time I have add the first point to my shopping cart. If I add a second element, the error disappears. Here are two pieces of keys to the code where I pull the item from the database information and then use the query requests to merge the query with the amount of shopping cart.

    <!-get-> Product Details

    < CFQUERY NAME='GetDetails'

    DATASOURCE = ' #request.ds # '

    Username = ' #request.dsuser # '

    PASSWORD = ' #request.dspass # ' >

    SELECT
    ItemNo,

    Agenda,

    Grades,

    Price,

    ImageSmall

    DE Products
    ItemNo IN (#QuotedValueList(GetCart.ItemNo) #)
    < / CFQUERY >

    <!-add the column "OrderQty"->

    < CFQUERY NAME="GetList" DBTYPE="query">

    SELECT
    GetDetails.ItemNo YOU ItemNo,

    GetDetails.Item point, AS

    GetDetails.Grades AS Grades,

    AS price, GetDetails.Price

    GetDetails.ImageSmall AS ImageSmall,

    GetCart.Quantity AS OrderQty

    DE GetDetails, GetCart
    GetDetails.ItemNo = GetCart.ItemNo
    < / CFQUERY >

    This is the error I get. The line number refers to the Q of Q above.

    Error running query of queries.

    Comparison = runtime exception.
    Comparison of Type incompatible Exception: on the left side and right side of the comparison operator "=" have incompatible types.
    Type of expression left side = "VARCHAR".
    Expression type side right hand = "DATE".

    I tried a lot of things affect a 'string' type to the right, but nothing seems to work.

    I would be very happy any help that I can get as I've spent countless hours trying to figure this.

    Thank you
    Steve

    Looks like the GetCart query is generated with functions to query coldfusion as opposed to a database query.  It also seems that the QueryNew function has the names of the fields, but not the types of data.  This means some trys to ColdFusion for the type of basic data on the first rows of data.

    Or it could be something else.

  • Query question queries

    You can query a query created using queryNew()?

    When I try the following code, I get an error:

    "Query of queries syntax error.
    Meeting "qData. user. "Incorrect conditional expression, waiting for an a [as | null | between | in | comparison] condition."

    Code:

    < cfset qData = queryNew ("tool, user, community, fm01, fm02, fm03, fm04, fm05, fm06, fm07, fm08, fm09, fm10, fm11, fm12, fy") >
    < cfset temp = #queryAddRow (qData) # >
    < cfset temp = #querysetCell (qData, "tool", "empty") # >
    < cfset temp = #querysetCell (qData, "user", "Bob") # >

    < cfquery dbtype = "query" name = "chkQdata" >
    SELECT *.
    OF qData
    WHERE qData.user = 'Bob '.
    < / cfquery >

    I just tried the code you provided, adding two cfdump Tags (the first to empty the qData query and the second to empty the chkQdata query). Everything worked well exactly as you had it on Railo 3.1. It did not work (threw the error you got) on CF 8.0.1.

    If I deleted the WHERE clause of the query of chkQdata, it runs (no error) in CF 8.0.1.

    For that it works as you want in CF8, change the user column. This seems to be a keyword for CF8. While I didn't check exactly, if I change your original request to be 'empty' = tool, it runs. In addition, rename the column user usr generates the script runs correctly.

    Here is the code that I had to work in CF8 and Railo 3.1:

    SELECT *.

    OF qData

    WHERE the usr = "Bob."

  • Query of queries

    I am having trouble with the query of queries in CF5. I have included my select statement in the attached code.

    I want to be able to do now is to select totals of the original with a query of queries request. For example, I need to know my total return compared to my new visitors total visitors (for the love of the query, a new visitor is a person whose FirstVisitDate statement date range the user specified [attributes.start to attributes.end] and a return visitor is someone whose FirstVisitDate does nto fall within the specified range.)

    I tried something like:
    < cfquery dbtype = "query" name = "GetNewHits" >
    Select Count (Visitor)
    Of QueryVisitors
    Where FirstVisit
    Between #attributes.start #.
    and #attributes.end #.
    < / cfquery >

    The above query (when he returned to all results) returns all records in the original request (for me, it seems that the FirstVisit field doesn't recognize as a date field). Can anyone offer any suggestions? Thank you

    -Daniel Casper

    I wish I had the choice to upgrade, but the company is not apparent from a local server and our Web host is 2 releases from behind. I think I found a way to implement without however using Q of Q.

    I put an increment conditional when the results are displayed, which checks the date against my range of user and then increments a variable newhit if it corresponds to the range, or increments a variable returnhit if it is not. Until now it works fine. If someone needs it, the increment of conditional is:



    Thank you all for your suggestions.

  • Query of queries on 2 data sources

    I'm doing a query of queries on 2 different data sources. I run a gaming site and have a 2 programs that are used for tracking. One is written in php, by someone else, following members point State. The other, I wrote it in CF, allows members to set priorities in Treasury. Both are independent on my server. What I'm trying to do is set up so that the program I wrote to FC shows the number of points, each Member has. I know how interrogate separate tables, but how do I combine them? In addition, how can I set up so that it only shows members that match. that is, I want to assure you that if John Smith has 100 points, the query will show John Smith 100 points on my table. Here is what the query looks like I did. As you can see, I'm confused about and WHERE statements. I played with him last night and could not make it work. Thank you.

    You can try the same correction/idea of what I posted in thread http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=1&catid=7

    Copied/Pasted from this thread:

    You can read through the first query and add content to a query to temp attributing some kind of field and then read through the second query and add same temp with a kind of field to the query. Then do a query of this temp query.

  • Query of queries error

    I use the same data source to create a query of queries, but one of my questions is not recognized. The codes and messages are the following:

    You do not use the datasource with a query of query property
    tag. When you do a query of query you are dealing with record sets
    memory. Delete the "datasource" setting in the third tag.

  • Query of queries syntax error.

    Hi all

    I have the following query:

    < cfquery 'agent' datasource = name = 'Datasourcename' >
    SELECT * FROM quote where status = 'pending '.
    < isDefined ("form.agent") cfif >
    AND agent = ' #FORM.agent # '.
    < / cfif >
    < / cfquery >

    Then I have the following query of this query

    < cfquery name = "totalvalue" dbtype = "query" >
    SELECT total MySQL under the name OF the agent
    < / cfquery >

    However, I get the following error:

    Query of queries syntax error.
    Met «SUM (value.» List of incorrect selection,

    on line 20, which is:

    < cfquery name = "totalvalue" dbtype = "query" >

    now, I'm sure it's identical to what ive used before, but the error. totals query works fine when querying the database direct, only had this error when I changed it to query the master query.

    I appreciate any help in advance, that no matter how I look at I can't see whats wrong!

    In my view, that this value is a reserved word which originally is probably your current error. I would rename this column or alias it in your initial query. Also, I would like to add value WHERE IS NOT NULL to your Q-Q to cover your NULL values.

    Phil

  • Query of queries (QofQ) escaped character problem

    Hi all

    I am trying to run a query or queires (QofQ) and I do a LIKE comparison which finds support ([]) characters in the string, but ColdFusion ignores the media. How can I escape the character of support? So far, I couldn't escape the percentage based on the Docs sign live ColdFusion. The error message I get when I run the query below is:

    «"" "Invalid escape sequence.»»»" Pairs of valid sequence for this escape character are: "------%", or "\".

    This is the query:
    < cfquery dbtype = "query" name = "getLogs" >
    SELECT *.
    OF GetLogs
    WHERE Description LIKE '\[User:#UserID#\]% %' ESCAPE ' \'
    < / cfquery >

    Thanks for your help!

    What of it?

    WHERE my Description LIKE ' % [[] user: #UserID #] %'

  • Hierarchical queries - problem with condition "begins by".

    Hi people

    I play with the connection by and start with clause and am faced with a particular problem which I can not solve...

    My data set is:

    Create table dates_q
    (start_date date,
    end_date date)
    /
    

    REM INSERTING into dates_q
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-JAN-14','DD-MON-RR'),to_date('10-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('11-JAN-14','DD-MON-RR'),to_date('20-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('10-MAR-14','DD-MON-RR'),to_date('20-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('21-MAR-14','DD-MON-RR'),to_date('31-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-APR-14','DD-MON-RR'),to_date('10-APR-14','DD-MON-RR'));
    

    Now I basically just want to get your hands on hierarchical queries and working with the syntax of various...

    What I now want is, start with the date of April 1 as my start date and work backward to build my 'tree '. The condition of my tree is between two rows; my start and end dates differ from 1 day. If they do not; I don't want these records in my tree.

    And using sys_connect_by_path, I want to get all the way from the root.

    Thus, for example,.

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
    

    I get the following output

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.01.201410.01.2014| 1 JANUARY 141
    11.01.201420.01.2014| 1 JANUARY 14 | JANUARY 11, 142
    11.01.201420.01.2014| JANUARY 11, 141
    10.03.201420.03.2014| MARCH 10, 141
    21.03.201431.03.2014| MARCH 10, 14. MARCH 21, 142
    01.04.201410.04.2014|10-MAR-14|21-MAR-14|01-APR-143
    21.03.201431.03.2014| MARCH 21, 141
    01.04.201410.04.2014| MARCH 21, 14. 1 APRIL 142
    01.04.201410.04.2014| 1 APRIL 141

    But for the moment I did not have any starting point... Now comes the FUN part...

    When I give the State of departure; I get a single row :-(

    Example of

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
     START WITH start_date = To_Date('01-apr-2014','dd-mon-yyyy');
    

    The result is

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.04.201410.04.2014| 1 APRIL 141

    Just a line...!

    I'm unable to understand this and work more and need help.

    The formation of the tree works only in a 'sense' and I'm going the other way around? Don't know what it means but just something that comes to mind. :/

    Thank you

    K

    P.S. - database is 10g R2.

    Hello

    Thanks for the display of the data of the sample; It is very useful.

    What do you expect the result will be and why?

    LEVEL = 1 contains all rows that meet the condition to START WITH.  The rows that meet the condition

    start_date = To_Date('01-apr-2014','dd-mon-yyyy')

    in this case?  Only the line you actually obtained.

    LEVEL = N (where N > 1) contains all rows that meet the conditions regarding some FRONT CONNECT BY rank level = N - 1.  Since the only line level = 1 to end_date = To_Date('10-apr-2014','dd-mon-yyyy'), lines satisfy the condition

    End_date PRIOR = (start_date - 1).

    ? None.  End_date PREREQUISITE is April 10, while rows with start_date April 11 would fulfill this condition, there is no line on LEVEL = 2 and the query stops there.

    You would have expected this from your previous results.  The line with the start_date April 1 had no children in the previous application, so there no children in any application that has the same State of CONNECT BY.

    Maybe you meant the CONNECT BY condtion to be

    End_date = BEFORE (start_date - 1).

  • Query before trigger problem

    Hello
    I have a datablock in the form that is based on a table of DB. There are a few searchable fields in the block, including the start and end dates. If I don't use no trigger prior request, reviews are interviewed very well. But I want to make a selection of beach between start and end_date fields. So I created a trigger before query and set with a new_where_clause all my query_fields and set it as DEFAULT for my DB block.

    SET_BLOCK_PROPERTY (block_id, default_where, where_clause);

    But when I see the toad session request, the query looks like

    WHERE (Champ_1 =: 1) and Champ_1 =: 1

    This means that its running the default where clause on the block and the clause of new_where at the same time.
    I checked the form and I did not all calls to execute the query.
    What can be the problem?

    Two possibilities: either concatenate values in the WHERE alike

    SET_BLOCK_PROPERTY('BLOCK', ONETIME_WHERE, 'FIELD LIKE '''||:BLOCK.ITEM||'%''');
    

    or set the values of request for items within a control block, as:

    :CONTROLBLOCK.ITEM:=:BLOCK.ITEM;
    SET_BLOCK_PROPERTY('BLOCK', ONETIME_WHERE, 'FIELD LIKE :CONTROLBLOCK.ITEM');
    
  • Query of queries to test for date null or empty

    I have problems with this request (in a function). The last condition in where clause must verify if a blank date or no, then check against the current date (which is fine), im aware that the syntax is wrong, but asked if someone could fix it for me to make it work.

    < name cfquery = "filterQuery" dbtype = "query" maxrows = "#arguments.top #" >
    Select * from getAllSaved
    where
    workFlowStatusId = < cfqueryparam cfsqltype = "CF_SQL_INTEGER" value = "" #application.const.WORKFLOW_LIVE # "/ >"
    and
    dateArchive > < cfqueryparam cfsqltype = 'CF_SQL_DATE' value = "#now ()" # "/ >"
    and
    dateLive < = < cfqueryparam cfsqltype = 'CF_SQL_DATE' value = "#now ()" # "/ >"
    and
    (dateExpiry is null or dateExpiry = ") or dateExpiry > < cfqueryparam cfsqltype = 'CF_SQL_DATE' value =" #now () "#" / > "
    < / cfquery >

    I feel stupid, although I would put a Fiver on having tried!

    Thank you

Maybe you are looking for

  • How can I get rid of the Sweetpacks on the tabs?

    Sweetpacks installed itself without asking, and I don't like it so how do I change in Firefox on the tab pages?

  • Satellite A100-543: the battery appears dead

    My battery died yesterday after I plugged it to my computer. In fact the computer turn off at this time. A burning smell has occurred and after, I tried to start the computer again and it works but the battery seems dead. When I'm on windows with the

  • Droid micro Turbo suddenly quiet?

    I had a Turbo Droid since launch and love it, but recently my microphone just stopped working. Google voice can't hear me, and the people on the calls barely can hear me. I want to emphasize, I never let drop the phone, or get wet. This problem start

  • Update bar color of char in the evolution of the temperature values

    Hello everyone. I actually read a temperature sensor and plot the data in the form of a bar graph. I am acquiring the data every second, and present them in a chart bar. the challenge is to show different colour on the bar chart that the temperature

  • Modules of Windows Installer error: 126

    My gateway has Vista Home Premium 64-bit with SP1. Windows updates do not work. After doing some research, I discovered that avast anti-virus might have removed TrustedInstaller.exe which I believe may have something to do with the problem although T