Jump to content

using distinct


jeff5656

Recommended Posts

I want to select records with DISTINCT only records with payment_type of a certain type are displayed once:

 

$query = "select distinct payment_type  from payments ";

 

So if I have payment_types of "A", "B" and "C"

each of those 3 will only be displayed once and not repeated.  The problem is, how do I SELECT more fields from each record?  I tried

$query = "select distinct payment_type, *  from payments ";

but that didn't work.

 

Link to comment
https://forums.phpfreaks.com/topic/244355-using-distinct/
Share on other sites

Also, don't use * unless you really do need all the columns.

 

I hear that is also a good idea to list the fields in the order they are in the database skipping the ones not needed. I could be wrong but that is what I heard.

Haven't heard of that, do you know for what reason(s)?

Link to comment
https://forums.phpfreaks.com/topic/244355-using-distinct/#findComment-1255054
Share on other sites

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.