mysql multiple values in one column code example

Example 1: mysql count multiple columns in one query

mysql count multiple columns in one query:
 SELECT 
        count(*)             as count_rows,
        count(col1)          as count_1,
        count(col2)          as count_2,
        count(distinct col1) as count_distinct_1,
        count(distinct col2) as count_distinct_2,
        count(distinct col1, col2) as count_distinct_1_2
    FROM `table` ;

Example 2: multi value column mysql

select * from celebrities 
where professions='002'          -- The only item in the list
or    professions like '002 %'   -- it might be first of several
or    professions like '% 002'   -- it could be the last of several
or    professions like '% 002 %' -- or in the middle

Tags:

Sql Example