Jump to content

Eliminate Duplicates from MYSQL Query


davefootball123

Recommended Posts

I have a MYSQL database that stores warning information for given regions, there are about 30 or 40 regions that I cover. If a warning is issued for the region the "type" row in the MYSQL database will be filled with the type of warning in effect for that given region. Often multiple regions have the same type of warning, and what I am looking to do is just get the first instance of each warning type in the database so I can create a legend with the warnings that are in effect. Any help would be great, if you need anymore information on how the db is setup, please let me know.

 

 

Thanks for your time, Dave

Link to comment
https://forums.phpfreaks.com/topic/280441-eliminate-duplicates-from-mysql-query/
Share on other sites

Use DISTINCT or a GROUP BY.

 

Since you are only wanting to get the warning types use DISTINCT. Something like:

 

SELECT DISTINCT warning_type FROM warnings

 

 

Also, why did you post this in the PHP forum and not the MySQL forum? << Moving >>

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.