从三个表中获取数据但出现SQL语法错误

时间:2018-10-19 14:35:24

标签: php mysql sql codeigniter

我正在从三个表中获取数据:

create external table parquet_db.bdv_table
(
registration_dttm timestamp comment 'Registration date',
id int comment 'id_for_person',
name string comment 'user_name',
email string comment 'email address'
)
ROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe'
STORED AS parquet
Location '/user/****/***'; 

错误:

  

发生数据库错误
  错误编号:1064
  
  您的SQL语法有误;检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第7行的'SELECT first_name,last_name,user_mobile,useralt_mobile from id = ='的用户中使用   
  SELECT $result = $this->db->query(" SELECT `meetings`.*, `follow_up`.id as follow_up_id, `follow_up`.comment as follow_up_comment, `follow_up`.date as follow_up_date, `follow_up`.time as follow_up_time, SELECT first_name, last_name, user_mobile, useralt_mobile from users where id = user_id, (SELECT address FROM day_location WHERE `meetings`.assigned_to_id = user_id AND `follow_up`.date = date LIMIT 1) AS location_name FROM meetings LEFT JOIN follow_up ON `meetings`.id = `follow_up`.`meeting_id` WHERE follow_up.`date` BETWEEN '{$fromDate_formated}' AND '{$toDate_formated}' " . ($user_id > 0 ? " AND `meetings`.assigned_to_id = '{$user_id}'" : '') . " ORDER BY `follow_up`.id DESC "); 。*,meetings。id作为follow_up_id,follow_up。comment作为follow_up_comment,follow_up。date作为follow_up_date,follow_up。time作为follow_up_time,SELECT用户的first_name,last_name,user_mobile,useralt_mobile,其中id = user_id,(从day_location WHERE follow_up。assigned_to_id = user_id AND meetings。date = date LIMIT 1选择地址)AS location_name来自会议LEFT JOIN follow_up ON follow_up。id = meetingsfollow_up进行后续跟踪。meeting_id位于'2018-10-01'和'2018-10-31'与date之间。 Assigned_to_id ='1'ORDER BY meetings。id DESC

可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

您需要替换以下内容:

SELECT first_name, last_name, user_mobile, useralt_mobile from users where id = user_id,

与此:

(SELECT first_name, last_name, user_mobile, useralt_mobile from users where id = user_id),

答案 1 :(得分:0)

要获取用户信息,您应该使用联接

private static IMarketBillingService mService;