Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)
edited by

Is something like this possible:

SELECT DISTINCT COUNT(productId) WHERE keyword='$keyword'

What I require right now is to get the number of unique product IDs connected with a keyword. The same product may be connected twice with a keyword, or more, however, I need only 1 time to be counted per product ID.

1 Answer

0 votes
by (12.7k points)
edited by

You can use the following code:

SELECT COUNT(DISTINCT productId) from  table_name WHERE keyword='$keyword'

Want to become a SQL Expertise? Join the SQL Course and get certified.

For more details on MySQL, refer to the below MySQL Tutorial video. 

Related questions

0 votes
1 answer
asked Dec 31, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 2, 2021 in SQL by Appu (6.1k points)

Browse Categories

...