query category wise dara

I have stored the some products and there respective category in sql.

Like this. Now I want fetch all product from table with respective category. output should be=

Topic sql dataset data-cleaning databases data-mining

Category Data Science


assuming your products table is called products the following sql statement would achieve this


SELECT DISTINCT id, category as name, 1 as flag_for_ca FROM products
UNION ALL
SELECT DISTINCT id, prodct as name, 0 as flag_for_ca FROM products

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.