Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Two table query doesn't work

Hi everyone,

I'm trying to perform a query with two tables because i want to load a single table with more info.

I've theese two tables, already loaded in qlik from a  db file:

Orders

Order Details

OrderID

OrderID
OrderDateProductID
ShipCityDiscount
Quantity

In script tag, I've done this:

[OrdersD]:

LOAD

  [OrderID],

  [OrderDate],

  [ShipCity],

    [ProductID],

    [Discount],

    [Quantity];

SQL SELECT `Orders`.`OrderID`

  `Orders`.`OrderDate`,

  `Orders`.`ShipCity`,

  `Order Details`.`ProductID`,

    `Order Details`.`Discount`,

    `Order Details`.`Quantity`

FROM `Orders`

WHERE `Orders`.`OrderID` = `Order Details`.`OrderID`;

But when I perform debugger, it's only says "Connector reply error: ***"

What I've done wrong?

Thank you.

Tags (2)
1 Solution

Accepted Solutions
Not applicable

Re: Two table query doesn't work

ok,

i fell very stupid: i notice just now that i've forgot a comma after

SQL SELECT `Orders`.`OrderID`


now it works!


sorry

11 Replies
micheledenardi
Valued Contributor

Re: Two table query doesn't work

I think you have to add "Order Details" in the "From" section...

[OrdersD]: 

LOAD  

  [OrderID], 

  [OrderDate], 

  [ShipCity], 

    [ProductID], 

    [Discount], 

    [Quantity]; 

SQL SELECT `Orders`.`OrderID` 

  `Orders`.`OrderDate`, 

  `Orders`.`ShipCity`, 

  `Order Details`.`ProductID`, 

    `Order Details`.`Discount`, 

    `Order Details`.`Quantity` 

FROM `Orders` , `Order Details`

WHERE `Orders`.`OrderID` = `Order Details`.`OrderID`;

Not applicable

Re: Two table query doesn't work

I've done wrong to copy my script, but there was Order Details table.

micheledenardi
Valued Contributor

Re: Two table query doesn't work

Try to split your select:

OrderHeader:

SQL SELECT

  `Orders`.`OrderID`,

  `Orders`.`OrderDate`,

  `Orders`.`ShipCity`

FROM `Orders`;


left join(OrderHeader)

OrderItems:

SQL SELECT

`Order Details`.`OrderID`,

`Order Details`.`ProductID`,

    `Order Details`.`Discount`,

    `Order Details`.`Quantity`

FROM `Order Details`;


Does it work ?

Not applicable

Re: Two table query doesn't work

no, it doesn't work like that.

but where are sql queries?

vishsaggi
Esteemed Contributor III

Re: Two table query doesn't work

May be this?

[OrdersD]:

LOAD 

  [OrderID],

  [OrderDate],

  [ShipCity],

    [ProductID],

    [Discount],

    [Quantity];

SQL SELECT `Orders`.`OrderID`

  `Orders`.`OrderDate`,

  `Orders`.`ShipCity`,

  `Order Details`.`ProductID`,

    `Order Details`.`Discount`,

    `Order Details`.`Quantity`

FROM `Orders`,

LEFT JOIN

`Order Details`

ON `Orders`.`OrderID` = `Order Details`.`OrderID`;

Not applicable

Re: Two table query doesn't work

nope!

I've tried to put that code into a single section, after the ones that upload table from my db file, but doesn't work.

When i perform debugger it stops at SQL SELECT ... row.

micheledenardi
Valued Contributor

Re: Two table query doesn't work

try to remove all the apex `

Not applicable

Re: Two table query doesn't work

nothing change

vishsaggi
Esteemed Contributor III

Re: Two table query doesn't work

I am sure you might be, just wondering to know if you are connecting to the database before loading using connection string.. Are you getting any results when you run only your SQL script on SQL editor?

Community Browser