0

我正在尝试进行两个select查询,以便第二个选择必须基于第一个。我给第一个表名“t1”并尝试根据第一个进行第二次选择,但最后我得到数据库错误。

SQL

SELECT startpoli_i ,
       finalpoli_i ,
       prosfora ,
       comments_pro ,
       accepted ,
       onoma01 ,
       epitheto01 ,
       email01 ,
       tilefono01 ,         
       weight1 ,
       depdate1 ,
       specialservices1 ,
       comments1 ,
       username01
FROM   (offers ,registration1 ,customer)  t1
WHERE  (
              offers.string_uniq regexp concat( :str)
       AND    registration1.username01 = offers.user_i
       AND    customer.startpoli1 = offers.startpoli_i
       AND    customer.finalpoli1 = offers.finalpoli_i )
UNION
SELECT startpoli_i ,
       finalpoli_i ,
       prosfora ,
       comments_pro ,
       accepted ,
       onoma01 ,
       epitheto01 ,
       email01 ,
       tilefono01 ,          
       weight1 ,
       depdate1 ,
       specialservices1 ,
       comments1 ,
       username01
FROM   offers ,
       registration1 ,
       customer
WHERE  offers.startpoli_i = t1.startpoli_i
AND    offers.finalpoli_i = t1.finalpoli_i          

我很确定该错误与我使用表名 t1 的方式有关。任何建议;

4

1 回答 1

0

选择 startpoli_i , finalpoli_i , prosfora , comments_pro , 接受 , onoma01 , epitheto01 , email01 , tilefono01 ,
weight1 , depdate1 , specialservices1 , comments1 , username01 FROM offer , registration1 , customer,(SELECT startpoli_i , finalpoli_i , prosfora , comments_pro , 接受 , onoma01 , epitheto01 , email01 , tilefono01 ,
weight1 , depdate1 , specialservices1 , comments1 , username01 FROM (offers ,registration1 ,customer) t1 WHERE ( offer.string_uniq regexp concat( :str) AND registration1.username01 = offer.user_i AND customer.startpoli1 = offer.startpoli_i AND customer.finalpoli1 = offer.finalpoli_i )) 在哪里 offer.startpoli_i = t1.startpoli_i AND offer.finalpoli_i = t1.finalpoli_i ;

于 2015-10-08T09:19:47.890 回答