Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Miguel_Angel_Baeyens

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

View solution in original post

6 Replies
syed_muzammil
Partner - Creator II
Partner - Creator II

Hi,

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

Regards,

Syed.

Miguel_Angel_Baeyens

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!

Anonymous
Not applicable
Author

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

Not applicable
Author

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.

Miguel_Angel_Baeyens

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
Author

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!