locked
SelectCommand from two tables SqlDataSource RRS feed

  • Question

  • User-521867967 posted

    Is it possible to write such (based on two tables) SelectCommnand in SqlDataSource?

    I have:

    SELECT "NAME",  "ESXI", "STATUS", "NOWY_SEM.ID", "SLOW_VSPHERE.ID" "PROJECT", "ONOFF", "LOCALIZATION", "PC_NAME", "STATUS_DATE", "DELETE_DATE", "MADE_DATE", "ONOFF_ORA", "ORACLE",  "RAM", "HDD", "DOMAIN", "PASSWORD_SYS", "PASSWORD_ORASYS", "IP", "MAC", "PARENTS", "KOLOR"  FROM "NOWY_SEM", "SLOW_VSPHERE"   WHERE ("NOWY_SEM.VSPHERE_ID" = "SLOW_VSPHERE.ID" )   ORDER BY "ESXI"


    SLOW_VSPHERE.ID" "NOWY_SEM.ID" "SLOW_VSPHERE.ID" "NOWY_SEM.VSPHERE_ID" - these generate errors  ORA-00904.

    I need to operate on two tables.

    Wednesday, January 15, 2014 4:22 AM

Answers

  • User-924551328 posted

    Select  x.FieldA, x.FieldB, x. FieldC, y.Field1, y.Field2 from Table1 x

    inner join Table2 y

    on x.FieldA = y.Field1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 21, 2014 7:55 AM

All replies

  • User697462465 posted

    Hi apatorrector,

    According to your code, I think this error is caused by the '"', you don't need put the column name into ".

    Please try to refer to the following code:

    SelectCommand="SELECT A.column1,B.column2 from A,B where A.column2=B.column2"

    Hope it helps.

    Best Regards,
    Terry Guo

    Thursday, January 16, 2014 1:36 AM
  • User-521867967 posted

    Thank you very much it's working now. However I have another problem:

    SelectCommand="SELECT NAME, SLOW_ESXI.ESXI, SLOW_APLIKACJE.APLIKACJE, NOWY_SEM.ESXI_ID, SLOW_ESXI.ID, NOWY_SEM.DOMAIN_NAME_ID, STATUS, NOWY_SEM.ID, SLOW_APLIKACJE.ID, PROJECT, SLOW_VSPHERE.VSPHERE, ONOFF, LOCALIZATION, PC_NAME, STATUS_DATE, DELETE_DATE, MADE_DATE, ONOFF_ORA, ORACLE, RAM, HDD, DOMAIN, PASSWORD_SYS, PASSWORD_ORASYS, SLOW_VSPHERE.ID, IP, MAC, PARENTS, KOLOR FROM NOWY_SEM, SLOW_VSPHERE, SLOW_APLIKACJE, SLOW_DOMAIN_NAME, SLOW_ESXI WHERE (NOWY_SEM.APLIKACJE_ID = SLOW_APLIKACJE.ID AND NOWY_SEM.VSPHERE_ID = SLOW_VSPHERE.ID AND NOWY_SEM.DOMAIN_NAME_ID = SLOW_DOMAIN_NAME.ID AND NOWY_SEM.ESXI_ID = SLOW_ESXI.ID ) ORDER BY ESXI" 

    When I execute this query in SQLTools I get 95 rows. In WebApplication I get 7. They seem distinct, because, IP's are the same in both, but in application

    each IP appears only once like in distinct query.

    What's the cause?

    Thursday, January 16, 2014 7:16 AM
  • User697462465 posted

    Hi apatorrector,

    The SelectCommand never do this distinct query automatically, so you need to check if you have query in same database.

    You can copy the SelectCommand text to the DBMS query page, and then run it, and compare the result with the SqlDataSource control.

    Hope it helps.

    Monday, January 20, 2014 5:30 AM
  • User-924551328 posted

    Select  x.FieldA, x.FieldB, x. FieldC, y.Field1, y.Field2 from Table1 x

    inner join Table2 y

    on x.FieldA = y.Field1

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 21, 2014 7:55 AM