Jump to content

MySQL query to have category appear once.


SauloA

Recommended Posts

I've been hitting my head against the wall trying to figure this out.  :facewall:

 

I have a video table and a video category table.  The tables are pretty much set up like the following:

 

video_tbl

------------

video_id

video_title

video_cat_id

 

video_cat_tbl

-----------------

video_cat_id

video_cat

 

I wrote this query and it works fine.

 

SELECT video_cat, video_title
FROM video_tbl, video_cat_tbl
WHERE video_cat_tbl.video_cat_id = video_tbl.video_cat_id

 

The only problem is that the category appears in every row, as it should.  I want it to appear only once.  Something like the following.

 

Video Category 1

--------------------

Video 1

Video 2

 

Video Category 2

---------------------

Video 3

Video 4

 

I'm trying to create a recordset that will display the videos under a certain category.  I was looking into using GROUP BY, DISTINCT, or JOIN in the SQL query but I can't figure out what to do.  I'd appreciate the help.

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.