0

I have big problem with SQLBase database, or it's engine. I have history with MySQL but not with SQLBase.

I have:

  1. Multiple tables joined together,
  2. work order that has,
  3. multiple values in a column and
  4. I want them on query result in a row.

For example, this is what I want:

table
ordernr|type|..............|productnr
-------------------------------------
1141356| v1 | .............|fe465
1141356| v2 | .............|hty546
1141356| v3 | .............|rgrg211
1454446| v1 | .............|dw885
1454446| v2 | .............|fee885
1454446| v3 | .............|wwf6664
1231231| v1 | .............|ff664
1591591| v1 | .............|gg123
1591591| v2 | .............|jj5891

query result
ordernr | .............|  v1 |  v2  |  v3
--------------------------------------------
1141356 | ............ |fe465|hty546|rgrg211  
1454446 | ............ |dw885|fee885|wwf6664
1231231 | ............ |ff664|  -   |   -
1591591 | ............ |gg123|jj5891|   -  

But when I am trying it I get only orders with one or two or three values. Depending how I write on the query, but I want all values showing. I tried using left join but no result.

Only ordernr comes from other table.

Please, ask if you need more information. I try my best to help.

EDIT: Hi! It works! Somehow my query started working as it should. But let me say that I have worked with MySQL over 10 years without any bigger hassle, but this SQLBase is giving me high blood pressure. :)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Now I have each v1, v2, v3 value on their own rows with ordernr. How I get this to single row? WHERE ordernr=1141356 AND (type='v1' or type='v2' or type='v3') – Teppo Toriseva May 03 '18 at 08:44
  • Read about "pivoting". If you clearly expressed what you wanted in a sentence & googled it you would get hits. – philipxy May 04 '18 at 10:35
  • I read about pivoting. But SQLBase didn't work with it, and I tried it multiple ways, but no desired result. I had to read SQLBase Language Reference multiple times until I managed to get the desired result. – Teppo Toriseva May 04 '18 at 13:07

1 Answers1

0

Not knowing the schema , have you tried Group By i.e. Group By ordernr , to give all on one row.

Steve Leighton
  • 790
  • 5
  • 15