set a mysql user variable per row? -


the following sql statement sets user variable @id i'm using in trailing subquery. problem @id variable gets set first items.id in result set - not "per row" - result subquery same every row in main select. know if there's way reset @id variable each row??

    select          items.id         ,items.title         ,@id := items.id         ,(             select                 group_concat(x.y)                             (                     select                         group_concat(ledger.stockcode) y                                             ledger                                             @id = ledger.itemid                     group                          ledger.stockcode                     having                         sum(ledger.stockqty) > 0                 ) x             ) extras             items             items.id = 196 

try query

select      a.id     ,a.title     ,b.y extras     items inner join     (select        group_concat(ledger.stockcode) y            ledger             ledger.itemid = 196     group        ledger.stockcode     having        sum(ledger.stockqty) > 0) b on     a.id = 196 , a.id = b.itemid 

Comments

  1. According to Stanford Medical, It's really the ONLY reason this country's women live 10 years more and weigh an average of 42 lbs less than we do.

    (And actually, it is not related to genetics or some secret-exercise and really, EVERYTHING around "how" they eat.)

    P.S, I said "HOW", and not "what"...

    Click this link to uncover if this easy test can help you find out your real weight loss possibilities

    ReplyDelete
  2. Casino site is the perfect venue for serious gambler
    Casino site is the perfect venue for serious gambler We are the perfect venue for serious gambler gambler. We are the perfect venue for serious gambler. luckyclub.live We are the

    ReplyDelete

Post a Comment

Popular posts from this blog

asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -

kineticjs - draw multiple lines and delete individual line -

thumbnails - jQuery image rotate on hover -