0

I am new to WP_LIST_TABLE and working on someone's else code. I have a couple of joins my query which you

SELECT *
FROM wp_o_students st
INNER JOIN wp_o_schools sc
ON st.school_id = sc.school_id
INNER JOIN wp_marks_list ml
ON st.student_id = ml.student_id
ORDER BY $orderby
LIMIT %d OFFSET %d

How do I set these columns to be sortable ?

'school_id' => __('School ID', 'olympiad'),
'student_id' => __('Student ID', 'olympiad'),
'test_code' => __('Test Code', 'olympiad'),
'division' => __('Division', 'olympiad'),
'class_highest' => __('Class Highest', 'olympiad'),
'cutoff_marks' => __('Cutoff Marks', 'olympiad'),
'scored_marks' => __('Scored Marks', 'olympiad'),
'marks' => __('Marks', 'olympiad'));

If I put aliases before column names, it won't work. It shows no results in table and its empty. What am I missing here?

0

Well, I found out that this can be achieved in 1 way. If I specify specific columns that I need instead of using * in my query, it will work.

Example:

SELECT st.student_id
FROM wp_o_students st
INNER JOIN wp_o_schools sc
ON st.school_id = sc.school_id
INNER JOIN wp_marks_list ml
ON st.student_id = ml.student_id
ORDER BY $orderby
LIMIT %d OFFSET %d

And for table columns:

'student_id' => __('Student ID', 'olympiad'),

Since there will be only 1 column with student_id, it will be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.