SauloA Posted August 13, 2009 Share Posted August 13, 2009 I've been hitting my head against the wall trying to figure this out. 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. Quote Link to comment https://forums.phpfreaks.com/topic/170013-mysql-query-to-have-category-appear-once/ Share on other sites More sharing options...
SauloA Posted August 13, 2009 Author Share Posted August 13, 2009 I forgot to mention that I'm using MySQL client version 5.0.75 Quote Link to comment https://forums.phpfreaks.com/topic/170013-mysql-query-to-have-category-appear-once/#findComment-897013 Share on other sites More sharing options...
aschk Posted August 13, 2009 Share Posted August 13, 2009 This is a formatting issue, not a MySQL issue. MySQL will always give you back a 2-dimensional (spreadsheet like) view of your data. So you need to use PHP (or another scripting language) to parse out the result into the view you want (3-dimensional). Quote Link to comment https://forums.phpfreaks.com/topic/170013-mysql-query-to-have-category-appear-once/#findComment-897089 Share on other sites More sharing options...
SauloA Posted August 13, 2009 Author Share Posted August 13, 2009 alright, I'll have to look into this. Thanks for helping a newb. Quote Link to comment https://forums.phpfreaks.com/topic/170013-mysql-query-to-have-category-appear-once/#findComment-897623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.