Jump to content

Archived

This topic is now archived and is closed to further replies.

yrrahxob

Problem with sorting in a query

Recommended Posts

Ok here is my problem. I have a query where I read a table T1 named

MHI_ISSUES and 9 of the columns in the table contain a user id which

can be from 1 to 3 digits. I also have another tabe T3 named MHI_USERS

that I use to get the user name for each of the columns in the first table

and then display them in a table on the screen. The headers on each

of the columns is a link refreshing the page and sending a sort by number

telling the query to sort by this column. When I do this, it sorts by

the user_id number but I want it to sort by the user name. Does anyone

know of a way to do this? I have my query shown below. Any help

would be greatly appreciated.

 

$qry=\"SELECT t1.issue_id,

t1.issue_name,

t2.status_desc,

t1.user_id,

t1.assigned_to,

t1.assigned_to_orig,

t1.modified_by,

t1.interested_party1_id,

t1.interested_party2_id,

t1.interested_party3_id,

t1.interested_party4_id,

t1.interested_party5_id

FROM

mhi_issues AS t1,

mhi_statuses AS t2,

mhi_users AS t3

WHERE

t1.status_id = t2.status_id AND (

t1.user_id = \'$user\' OR // $user is the 1 to 3 digit user_id number

t1.assigned_to = \'$user\' OR

t1.assigned_to_orig = \'$user\' OR

t1.interested_party1_id = \'$user\' OR

t1.interested_party2_id = \'$user\' OR

t1.interested_party3_id = \'$user\' OR

t1.interested_party4_id = \'$user\' OR

t1.interested_party5_id = \'$user\' OR

t1.modified_by = \'$user\') AND

t3.user_name = \'$user_name\' // $user_name is the user_name field which I get when the page is loaded

ORDER BY $sort_field

LIMIT $seek_pos, $limit_return\";

Share this post


Link to post
Share on other sites

what are the links passing into $sort_field? echo it out to be sure it is beind passed correctly.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.