Jump to content

query based on 2 conditions


jeff5656

Recommended Posts

I want to select if the doc_type is either s OR f but this doesn't work:

 

$query2 = "SELECT * FROM members WHERE doc_type='s' && doc_type= 'f' ORDER BY username";

 

Also If I want to do two sorts can I do this:

	$query2 = "SELECT * FROM members WHERE doc_type='s' && doc_type= 'f' ORDER BY doc_type, username";

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/178784-query-based-on-2-conditions/
Share on other sites

I know that logical operators work in other databases like Oracle.

 

You are using a logical AND operator. Use OR (or ||):

"SELECT * FROM members WHERE doc_type='s' OR doc_type= 'f' ORDER BY username";

 

Yes, you can sort twice like that. It sorts by the first, then the second, etc.

Archived

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

×
×
  • Create New...

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.