• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Mysql

Hi i have a database with many rows. So i want to make a query to select all number for example i have category 2,3,4,5,2,2,2,2,2,3,4,4,5,3,1 so i want to mysql delete every category which repeat.
0
umaxim
Asked:
umaxim
1 Solution
 
IrishStudentCommented:
I'd need to see your table structure, what is the purpose of this number.
0
 
umaximAuthor Commented:
id       int(11)                   No             auto_increment       Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      num       varchar(20)       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      desc_text       text       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      category       text       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      sponsor       text       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      title       text       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
      image       varchar(20)       utf8_general_ci             No                   Browse distinct values       Change       Drop       Primary       Unique       Index       Fulltext
0
 
umaximAuthor Commented:
CREATE TABLE `prizes` (
  `id` int(11) NOT NULL auto_increment,
  `num` varchar(20) NOT NULL,
  `desc_text` text NOT NULL,
  `category` text NOT NULL,
  `sponsor` text NOT NULL,
  `title` text NOT NULL,
  `image` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
umaximAuthor Commented:
The numbers is category. I want to get all category and make as menu
0
 
TimBareCommented:
Do you want to delete duplicates, or get all of a single category to create a menu item w/ sub-menus, then the next category, etc?
0
 
umaximAuthor Commented:
i want to get list of it. Just list so i can use it in menu. like
12
22
33
44
0
 
Chris StanyonCommented:
Give this a go
SELECT DISTINCT category FROM prizes ORDER BY category;

Open in new window

0
 
jessegivyDeveloperCommented:
The most standard way to accomplish this would be with a look-up table and foreign key to the table you speak of...

Mr. Stanyon does have the short answer of course *hat tip*.  If you're expecting the table to have over a couple thousand rows you might want to convert it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now