Hi friends!
i have a drop down combo box which holds names of persons with php mysql order by asc query
like a's name put in 1st and after b's and c's and in last it shows z's name
now i want that if it will show tahir name in top and after that it will show all other name in asc order, is it possible?
like this
1.tahir
2.amir
3,ahmed
4.akram
5,aslam
6,bilal
7.charlie
8.zahid

i hope you got my point.
here is the query
$query = "SELECT * FROM person ORDER BY fullname ASC";

Recommended Answers

All 3 Replies

SELECT * FROM person WHERE fullname = 'tahir' LIMIT 1
UNION
SELECT * FROM person where fullname <> 'tahir' ORDER BY fullname ASC

pritaeas thanks for your reply but its not working , its showing me the result as previous still i can see on top old results like ascending one's

//$query = "SELECT * FROM person ORDER BY fullname ASC";
                        $query = "SELECT * FROM person WHERE fullname = 'Mohammad Ismail Shaikh' LIMIT 1
                        UNION
                        SELECT * FROM person WHERE fullname <> 'Mohammad Ismail Shaikh' ORDER BY fullname ASC";

I think it incorrectly uses the order by for the whole result, try with parenthesis.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.