PDA

View Full Version : query problem


ratamaster
11-18-2005, 01:27 PM
I have the table ventypecat which has the VenCatId values (int):

VenId VenTypeId VenCatId
28------ 1------ 16
28------ 2------ 20

In my query I have to output VenCatId values WHERE they are VenTypeId=1 AS Distributors
and WHERE they are VenTypeId=2 AS Service
But I have no Idea how can I achieve this in the same query:




SELECT vendors.*, group_concat( DISTINCT countries.CtryNam ) AS Country, group_concat( DISTINCT ventypecat.VenCatId ) AS Distributor
FROM vendors, countries, ventypecat
WHERE vendors.VenId = ventypecat.VenId AND vendors.CtryId = countries.CtryId AND ventypecat.VenTypeId =1
GROUP BY vendors.VenNam


As you can see now I'm outputing just VenCatId WHERE ventypecat.VenTypeId =1, but I need both in separated colums.

Thanks for ALL your help !!

Velox Letum
11-18-2005, 08:28 PM
Can you just GROUP BY the VenTypeId? Or did I miss what you wanted?