sqlite - turn two sql queries into one with a subquery: top 1 row of query from subquery -


i have following table structure:

wwwid   eeeid   www1    eee1    property1   property2 1       1       aa2     ddd1    bbb1        adfsdfs 2       1       aa1     ddd1    bbb2        lasdkjfs 3       1       aa3     ddd1    bbb3        doafijsd 4       1       aa1     ddd1    bbb4        doifjdoifs 5       2       bb2     ddd2    ccc1        dofidsjfois 6       2       bb3     ddd2    ccc2        peowrpoerwe 7       2       aa1     ddd2    ccc3        dpofsdopfsd 

my first query is:

select distinct eeeid tinf www1='aa1' 

this query returns:

eeeid 1 2 

then pass results second query:

select * tinf eeeid='" & eeeid & "' limit 1 

(top 1 in mysql syntax)

final result:

eeeid, eee1, property1, property2: 1, ddd1, bbb1, adfsdfs 2, ddd2, ccc1, dofidsjfois 

i tried combining 1 query

select * tinf eeeid in (        select distinct eeeid tinf www='aa1' ) limit 1 

but apparently brings 1 total result, not 1 result per subquery result. there way of doing in single query ?

thank in advance

you want 1 output row each eeeid group; done group by.

sqlite allows bare columns in aggregate queries; can use min() row smallest value in group, or not use min() random row group:

select *,        min(wwwid)  -- optional tinf eeeid in (select eeeid                 tinf                 www1 = 'aa1') group eeeid; 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -