mysql - 在第一次选择的基础上进行第二次选择

标签 mysql sql select-query

我正在尝试进行两个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/

相关文章:

php - Symfony 2 中的联接表

sql - PostgreSQL:获取双括号之间的字符串

mysql - 从两个表中选择最大值 : which one is better

mysql - CakePHP 查询中 strtotime() 的替代方案

sql-server - 查询优化

sql - 根据年份是否(完全)包含在日期范围内进行匹配

sql - 十进制数的 Oracle ceil

mysql - 我需要加快对大表的特定 mysql 查询

sql - 从 column=column 的表名中选择 count(1)

mysql concat 从选择结果