Ответы пользователя по тегу MySQL
  • Как лучше составить SQL запрос?

    @sergmit
    Или так:
    $project_id = empty($_SESSION['selected_menu_item_id']) ? '' : 
        "tasks.project_id = ".$_SESSION['selected_menu_item_id']." AND";
    $current_tasks_list_query = "SELECT
            tasks.id AS ID,
            tasks.name AS TASK_NAME,
            tasks.deadline_datetime AS TASK_DEADLINE,
            tasks.status AS TASK_STATUS,
            projects.name AS PROJECT_NAME
            FROM tasks 
            JOIN projects
            ON tasks.project_id = projects.id
            WHERE
            $project_id
            tasks.author_id = '".$USER['id']."'";
    Ответ написан
    Комментировать