Update in multiple tables in join query

QuestionsUpdate in multiple tables in join query
Prasad Ravi asked 6 years ago

Hi i have a join query and first i am unable to display and update data with join query as i have already shared you on mail. my query is as follows :
select * from candidate where owner is null;SELECT
    candidate.candidate_id AS candidateID,
    candidate.first_name AS firstName,
    candidate.last_name AS lastName,
    candidate.state AS state,
    candidate.city AS city,
    candidate.phone_cell AS phone_cell,
    candidate.phone_work AS phone_work,
    candidate.key_skills AS key_skills,
    candidate.profile AS profile,
    candidate.source AS source,
    candidate.email1 AS candidateEmail,
    candidate.work_auth AS WorkVisa,
    candidate.total_exp AS ‘TotalExeprience’,
    candidate_joborder.status AS jobOrderStatus,
    DATE_FORMAT(candidate_joborder.date_created,
            ‘%m-%d-%y’) AS dateCreated,
    UNIX_TIMESTAMP(candidate_joborder.date_created) AS dateCreatedInt,
    candidate_joborder_status.short_description AS status,
    candidate_joborder.candidate_joborder_id AS candidateJobOrderID,
    candidate_joborder.rating_value AS ratingValue,
    candidate_joborder.resume_no AS resumeNo,
    candidate_joborder.candidate_type AS candidateType,
    candidate_joborder.submission_rate AS submissionRate,
    candidate_joborder.employer_name AS employerName,
    candidate_joborder.employer_email AS employerEmail,
    owner_user.first_name AS ownerFirstName,
    owner_user.last_name AS ownerLastName,
    IF((SELECT
                COUNT(*)
            FROM
                candidate_joborder_status_history
            WHERE
                joborder_id = 101987
                    AND candidate_id = candidate.candidate_id
                    AND status_to = 400
                    AND site_id = 1) > 1,
        1,
        0) AS submitted,
    added_user.first_name AS addedByFirstName,
    added_user.last_name AS addedByLastName
FROM
    candidate_joborder
        LEFT JOIN
    candidate ON candidate_joborder.candidate_id = candidate.candidate_id
        LEFT JOIN
    user AS owner_user ON candidate.owner = owner_user.user_id
        LEFT JOIN
    user AS added_user ON candidate_joborder.added_by = added_user.user_id
        LEFT JOIN
    candidate_joborder_status ON candidate_joborder.status = candidate_joborder_status.candidate_joborder_status_id
WHERE
    candidate_joborder.joborder_id = 101987
        AND candidate_joborder.site_id = 1
        AND candidate.site_id = 1
GROUP BY candidate_joborder.candidate_id

query is working fine in my application as well as mysql .

And my data array is :
$col = array();
$col[“title”] = “Candidate ID”; // caption of column
$col[“name”] = “candidateID”;
$colj[“dbname”] = “candidate.candidate_id”;
$col[“width”] = “30”;
$col[“editable”] = false;
$cols[] = $col;

at the time of edit it is giving following error.

Couldn’t execute query. Unknown column ‘candidateID’ in ‘where clause’ – UPDATE candidate SET `firstName`=’chaitanya’,`phone_cell`=’123-123-1234′

I have to update all fileds based on there table.

Also i am trying to get all the ids from get or post method to a new page same like export how it can be done .

Please suggest.

 

Thank you

1 Answers
Abu Ghufran Staff answered 6 years ago

In order to edit field, exact table field name must be provided in
$col[“name”] = “…”;

Alias will not work. dbname property only work in where and order by clause.

PS: Use either forum or email. Don’t use both.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Prasad Ravi replied 6 years ago

It is not working for update join tables like i have to update employer_name in candidate_joborder table. How it will work. It is updating only candidate table data

Your Answer

18 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?