根据连接结果插入mysql表

时间:2017-01-29 05:10:54

标签: mysql

我的class FloatingTabBarPercentDrivenInteraction: UIPercentDrivenInteractiveTransition { var interactionInProgress = false private var shouldCompleteTransition = false private weak var tabBarViewController: FloatingTabBarViewController! func wireToViewController(viewController: UIViewController!) { self.tabBarViewController = viewController as! FloatingTabBarViewController prepareGestureRecognizerInView(view: viewController.view) } private func prepareGestureRecognizerInView(view: UIView) { let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handleGesture(gestureRecognizer:))) view.addGestureRecognizer(gestureRecognizer) } func handleGesture(gestureRecognizer: UIPanGestureRecognizer) { let translation = gestureRecognizer.translation(in: gestureRecognizer.view) var progress = (translation.x / 200) progress = CGFloat(fminf(fmaxf(Float(progress), 0.0), 1.0)) switch gestureRecognizer.state { case .began: interactionInProgress = true tabBarViewController.selectedIndex = 1 case .changed: shouldCompleteTransition = progress > 0.3 update(progress) case .cancelled: interactionInProgress = false cancel() case.ended: interactionInProgress = false if !shouldCompleteTransition { cancel() } else { finish() } default: print("Unsupported") } } } if (ds.Tables.Count > 1) { if (ds.Tables[0].Rows.Count > 0) { dt = ds.Tables[0]; dr = dt.Rows[0]; TempData["AgentId"] = dr[0].ToString(); TempData["AgentCode"] = dr[1].ToString(); TempData["CenterName"] = dr[2].ToString(); TempData["LevelName"] = dr[3].ToString(); Session["AgentId"] = dr[0].ToString(); Session["LogInSession"] = SessionId; return RedirectToAction("DashBoard", this.View(new AgentDetails { AgentId = Session["AgentId"].ToString() })); //return this.View("DashBoard", new AgentDetails { AgentId = Session["AgentId"].ToString()}); } 查询按预期工作:

MySQL

但是我的意图是将这些值放入表格中。

目前我想将结果放在新表JOIN

SELECT subjectmie_subclasss.id AS subcl, subjectmie_classs.id AS cla, 
    subjectmie_subject.id AS subj,
    CONCAT_WS(', ' ,subjectmie_subclasss.subclasss, subjectmie_classs.classs, subjectmie_subject.subject)
    AS subjectcl        
FROM subjectmie_subclasss
INNER JOIN subjectmie_subject
    ON subjectmie_subject.id = subjectmie_subclasss.subject_id
LEFT JOIN subjectmie_classs
    ON subjectmie_classs.id = subjectmie_subclasss.classs_id;

subject_classs显然不正确,它在我执行查询之前显示INSERT INTO subject_classs (subject_id, classs_id, subclasss_id, subject_classs) SELECT subjectmie_subject.id AS subj, subjectmie_classs.id AS cla, subjectmie_subclasss.id AS subcl, CONCAT_WS(', ' ,subjectmie_subclasss.subclasss, subjectmie_classs.classs, subjectmie_subject.subject) AS subjectcl FROM subjectmie_subclasss INNER JOIN subjectmie_subject ON subjectmie_subject.id = subjectmie_subclasss.subject_id LEFT JOIN subjectmie_classs ON subjectmie_classs.id = subjectmie_subclasss.classs_id; VALUES(subj, cla, subcl, subjectcl) 中的错误,因此查询逻辑错误。有人可以告诉我如何在我的QUERY查询中使用MySQL workbench

1 个答案:

答案 0 :(得分:1)

只需删除values子句即可:

INSERT INTO subject_classs
    (subject_id, classs_id, subclasss_id, subject_classs)
    SELECT subjectmie_subject.id AS subj, subjectmie_classs.id AS cla, 
        subjectmie_subclasss.id AS subcl,  
        CONCAT_WS(', ' ,subjectmie_subclasss.subclasss, subjectmie_classs.classs, subjectmie_subject.subject)
        AS subjectcl        
    FROM subjectmie_subclasss
    INNER JOIN subjectmie_subject
        ON subjectmie_subject.id = subjectmie_subclasss.subject_id
    LEFT JOIN subjectmie_classs
        ON subjectmie_classs.id = subjectmie_subclasss.classs_id;