hippietrail
hippietrail

Reputation: 16974

How to combine results from two rather different YQL SELECTs (not a subselect)?

I have the following two YQL queries, each of which work fine on their own, but I'm pretty sure there's a way I haven't been able to find to fetch them both in a single more complicated query:

SELECT * FROM xml WHERE url="http://www.google.com/ig/api?weather=Tbilisi"
AND itemPath="//current_conditions/temp_c"

and

SELECT * FROM html WHERE url='http://amindi.ge/'
AND xpath="//*[@id='maincityholder']/h1"

The questions here with similar wording all turn out to be questions about subselects, use query.multi which doesn't seem to exist any more, or select something other than * which I couldn't get to work with either of my queries even in isolation.

It could be that the itemPath and the xpath clauses are the problem, but as I say I can't get either to work without these. Am I missing something or is this not possible with my particular queries?

Upvotes: 3

Views: 1123

Answers (1)

salathe
salathe

Reputation: 51950

The query.multi table exists in the same place it always has. Did you forget to load that table (or the usual env=store://datatables.org/alltableswithkeys)?

There's also a yql.query.multi table, which is used in exactly the same way as query.multi but exists in YQL proper, so does not require the data table to be loaded into the environment.

The following query, taking your individual queries (and changing/escaping quotes where necessary)

SELECT * FROM yql.query.multi WHERE queries='
    SELECT * FROM xml WHERE url="http://www.google.com/ig/api?weather=Tbilisi"
    AND itemPath="//current_conditions/temp_c";
    SELECT * FROM html WHERE url="http://amindi.ge/" 
    AND xpath="//*[@id=\'maincityholder\']/h1"
';

Gives

<results>
    <results>
        <temp_c data="-2"/>
    </results>
    <results>
        <h1>6&deg;</h1>
    </results>
</results>

(Try it in the YQL console)

Upvotes: 4

Related Questions