samedi 9 juillet 2016

select record where condition 1 followed condition 2

In my project I have query like.

$mainquery="SELECT * 
            FROM project 
            WHERE ProjectType='Current Projects' and Status='In Progress' 
            order by projectid";

and

$mainquery="SELECT * 
            FROM project 
            WHERE ProjectType='Current Projects' and Status='Not Started' 
            order by projectid";

now I want combine both and want all record where Status='In Progress' and then Status='Not Started'. I tried this.

$mainquery="SELECT * 
            FROM project 
            WHERE ProjectType='Current Projects' and (Status='In Progress' or Status='Not Started') 
            order by projectid";

but it gives combine result with Status='In Progress' and Status='Not Started'. I want first all record of Status='In Progress' and then all record of Status='Not Started'.

Aucun commentaire:

Enregistrer un commentaire