| Author |
Topic |
|
rtr1900
Starting Member
48 Posts |
Posted - 2008-02-08 : 08:29:43
|
| Hi,I tried to do an INNER JOIN with multiple tables.When I use two table I have no problems. But when I use a third table I get this error:Error de sintaxis (falta operador) en la expresión de consulta 'MAE_LME.COD_ART=MAE_LPED.COD_ART INNER JOIN MAE_LAB ON MAE_LME.COD_LAB=MAE_LAB.COD_LAB'. Translated: that it misses an operator.But where?My sql code that works is:SELECT MAE_LME.cod_ALB FROM MAE_LME INNER JOIN MAE_LPED ON MAE_LME.COD_ART=MAE_LPED.COD_ARTbut when I add another table it doesn´t go well:SELECT MAE_LME.cod_ALB FROM MAE_LME INNER JOIN MAE_LPED ON MAE_LME.COD_ART=MAE_LPED.COD_ART INNER JOIN MAE_LAB ON MAE_LME.COD_LAB=MAE_LAB.COD_LABany help is welcome.Thx |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-08 : 08:37:37
|
| HiI've just run : SELECT MAE_LME.cod_ALB FROM MAE_LME INNER JOIN MAE_LPED ON MAE_LME.COD_ART=MAE_LPED.COD_ART INNER JOIN MAE_LAB ON MAE_LME.COD_LAB=MAE_LAB.COD_LABthrough the Parser and it looks OK , that was a direct COPY and PASTE from your original postJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
rtr1900
Starting Member
48 Posts |
Posted - 2008-02-08 : 08:52:53
|
| Hi JackV,I just copied it from youe message. And it works...... Strange!!!!Then I checked my code and ...yes it is the same.....Oh Boy! maybe some Ghost are hauntig my Server :-) :-)Well, problems is solved..... now I will add more tables to it...Thx for responding! |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-02-08 : 08:59:21
|
| It may have been that when you were running the code there were some spaces missingJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
|
rtr1900
Starting Member
48 Posts |
Posted - 2008-02-11 : 07:13:43
|
| I tried again this morning this:SQL="SELECT MAE_LME.*,MAE_LAB.* FROM MAE_LME INNER JOIN MAE_LPED ON MAE_LME.COD_ART=MAE_LPED.COD_ART INNER JOIN MAE_LAB ON MAE_LME.COD_LAB=MAE_LAB.COD_LAB"And it gives me an error on that it is missing an operator.What can be wrong here?Thx in advance |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-11 : 07:24:00
|
How are you executing your dynamic SQL? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
rtr1900
Starting Member
48 Posts |
Posted - 2008-02-11 : 07:27:39
|
| From a webpage ASP using ODBC |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-11 : 07:28:58
|
| What is the need of SQL= here? Are you using dynamic SQL?I cant see any necessity for using it. Do you have some more dynamic filteration to follow this chunk of code? |
 |
|
|
rtr1900
Starting Member
48 Posts |
Posted - 2008-02-11 : 07:30:12
|
| In aSP you need to write the Syntax in a string, in this case it it named SQL. (you can name it anything you want). The you execute the string using ODBC conection with the DB |
 |
|
|
anuksundar
Starting Member
4 Posts |
Posted - 2008-02-21 : 07:24:55
|
| create table emp1(emp_id int,emp_name varchar(20),emp_sal decimal(10,2))create table emp(emp_id int,emp_name varchar(20))create table product(prod_id int,prod_name varchar(20),emp_id int)insert into emp values(1,'suja')insert into emp values(2,'anu')insert into emp values(3,'shankar')insert into emp values(4,'aparna')insert into emp values(5,'usha')insert into emp1 values(1,'suja',10000)insert into emp1 values(2,'anu',5000)insert into emp1 values(3,'shankar',20000)insert into emp1 values(4,'aparna',40000)insert into emp1 values(5,'usha',50000)insert into product values(100,'table',1)insert into product values(101,'chair',1)insert into product values(102,'mobile',2)insert into product values(103,'computer',3)insert into product values(104,'books',4)insert into product values(105,'bag',5)insert into product values(106,'pen',5)insert into product values(107,'pen',5)above are the tables and datas here is the queryselect e.emp_id,e.emp_name,e1.emp_sal,p.prod_name from emp e inner join emp1 e1 on e.emp_id = e1.emp_idinner join product p on e.emp_id = p.emp_idanuradhak |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-21 : 07:42:23
|
| Are you really using SQL Server? The query works just fine at my end.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|