在表project_users中显示基于user_ID的字段

时间:2018-05-26 01:09:09

标签: mysql sql phpmyadmin

enter image description here

这是我的数据库,我正在尝试查找查询。我的查询应根据user_id中的project_users打印出项目值名称,说明和图片。项目通过任务连接。

如何根据与user_ID相关联的task_ID获取项目值,该project_ID通过project_task表格导致project_ID

project中{p> project_ID为2 project_tasktask_ID中的任务为2,task_ID为3 project_usersimport MySQLdb import sys import os result = os.listdir("C:\\Users\\msalimi\\Google Drive\\s\\Discharge_Summary") for x in result: db = MySQLdb.connect("localhost", "root", "Pass", "myblog") cursor = db.cursor() file1 = os.path.join(r'C:\\Discharge_Summary\\'+x) cursor.execute("LOAD DATA LOCAL INFILE '%s' INTO TABLE clamp_test" %(file1,)); db.commit() db.close() include_package_data是3。

1 个答案:

答案 0 :(得分:1)

加入表并在user_id子句中具有WHERE的条件。

SELECT DISTINCT p.project_name,
                p.project_description,
                p.project_image
       FROM project p
            INNER JOIN project_task t
                       ON t.project_id = p.project_id
            INNER JOIN project_users pu
                       ON pu.task_id = t.task_id
       WHERE pu.user_id = <user id>;