我正在尝试进行两个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 的方式有关。任何建议;
最佳答案
选择startpoli_i,
最终poli_i,
原发树,
评论专业版,
接受,
奥诺马01 ,
上词01 ,
电子邮件01,
tilefono01,
重量1 ,
依赖1 ,
特殊服务1 ,
评论1 ,
用户名01
从优惠,
注册1 ,
客户,(选择 startpoli_i ,
最终poli_i,
原发树,
评论专业版,
接受,
奥诺马01 ,
上词01 ,
电子邮件01,
tilefono01,
重量1 ,
依赖1 ,
特殊服务1 ,
评论1 ,
用户名01
FROM(优惠、注册1、客户)t1
在哪里 (
Offers.string_uniq 正则表达式 concat( :str)
AND Registration1.username01 = Offers.user_i
AND customer.startpoli1 = Offers.startpoli_i
并且 customer.finalpoli1 = Offers.finalpoli_i ))
WHERE Offers.startpoli_i = t1.startpoli_i
AND Offers.finalpoli_i = t1.finalpoli_i ;
关于mysql - 在第一次选择的基础上进行第二次选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32997369/