Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
Not applicable

SQL sentence problems...

Hi,

it seems that theres a problem with the following SQL sentence:

SELECT *

FROM table1, table2;

WHERE table1.id = 3 AND table1.name = table2.id

table1.name and table2.id contains "name". It's just a diferent field name with same info.

I've tested it in my SQL frontend tool and it works perfectly.

Any ideas....???

Thank you in advance!

1 Solution

Accepted Solutions
MVP
MVP

SQL sentence problems...

Hi,

Take this example:

Data:LOAD Field1, Field1_2, Field2;SQL SELECT t1.Field1, t2.Field1 AS Field1t2, t2.Field2 FROM table1 t1INNER JOIN table2 t2 on t1.name = t2.idWHERE t1.id = 3;


Hope that helps

6 Replies
syed_muzammil
Contributor II

SQL sentence problems...

Hi,

You will have to specify all the feild names instead of '*' (in the load script also).

Regards,

Syed.

MVP
MVP

SQL sentence problems...

Hello,

That usually happens to me in one of the following:

1.- There are duplcate names of fields in the query, when they come from different tables, and not using a LOAD statement.

2.- The ODBC / OLEDB driver doesn't understand a comma or some other character in the FROM clause.

I have worked that around renaming fields with a LOAD stantement or using an INNER JOIN clause instead of a FROM / WHERE table.field = table2.field2.

Hope that helps!

mov
Esteemed Contributor III

SQL sentence problems...

Maybe it is just a mistyping, but please check it - there must not be ';' before 'WHERE'.

Not applicable

SQL sentence problems...

Ops.... mistyping!

There's no ";" after the from line.

Both tables have fields with same names (but different data!) and linked fields are designed with different names (table1.id is linked with table2.name but there's also a table2.id field).

Miguel (or anybody), could you give me an example in order to solve it? (I'm a database newbie....).

Thank you very much for alll the answers.

MVP
MVP

SQL sentence problems...

Hi,

Take this example:

Data:LOAD Field1, Field1_2, Field2;SQL SELECT t1.Field1, t2.Field1 AS Field1t2, t2.Field2 FROM table1 t1INNER JOIN table2 t2 on t1.name = t2.idWHERE t1.id = 3;


Hope that helps

Not applicable

SQL sentence problems...

There's a mistake explaining that there's no FROM linked with the previous LOAD.

Anyway, it works and I've loaded all the info I need.

Thank you so much!