我正在尝试进行两个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的方式有关。任何建议;

最佳答案

SELECT startpoli_i,
       finalpoli_i,
       前列腺
       comments_pro,
       被接受
       onoma01,
       上皮01
       email01,
       tilefono01,
       重量1
       depdate1,
       特殊服务1,
       评论1,
       用户名01
从报价,
       注册1,
       客户,(SELECT startpoli_i,
       finalpoli_i,
       前列腺
       comments_pro,
       被接受
       onoma01,
       上皮01
       email01,
       tilefono01,
       重量1
       depdate1,
       特殊服务1,
       评论1,
       用户名01
FROM(要价,注册1,客户)t1
在哪里(
              offer.string_uniq正则表达式concat(:str)
       AND registration1.username01 = offers.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;

关于mysql - 根据第一的第二选择,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32997369/

10-12 02:39