I have a database with races in. I want to check to see if within a group a column contains a value.
So something like:
SELECT count(*) as total
FROM table
WHERE column contains value 'hurdal'
OR column contains value 'chase'
GROUP BY column
Then I can see how many contain that value within the group.
select count(*) as total from table where column in ('hurdal', 'chase') group by column
IN
checks the column value is contained within the group specified, thus this will match any row where column
is either hurdal
or chase
.
For more information, the MySQL specific documentation is here , but this is a standard SQL operator so should work on any DBMS.
In MySQL for checking contain you need LIKE operator, Like this:
SELECT count(*) as total
FROM table
WHERE column LIKE '%hurdal%'
OR column LIKE '%chase%'
GROUP BY column
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.