创建查询以显示longtext字段中特定结果的计数

时间:2013-09-11 23:01:13

标签: mysql sql database

您好,我首先是一个SQL新手,需要一些帮助。我找不到与我完全一样的问题。

(select count(*)  from table  where Column_x like '%text1%')
(select count(*)  from table  where Column_x like '%text2%')
(select count(*)  from table  where Column_x like '%text3%')

所以我希望搜索返回

case 1  | Case 2  | Case 3
xtimes   ytimes     ztimes

任何帮助都会很棒,无论是显示查询结果还是创建临时表。

干杯,

我找到的解决方案如下

Select * from(
(select count(*)  as col1 from table  where Column_x like '%text1%')col1,
(select count(*)  as col2 from table  where Column_x like '%text2%')col2,
(select count(*)  as col3 from table  where Column_x like '%text3%')col3

1 个答案:

答案 0 :(得分:0)

select * from (
        (select count(*)  from table  where Column_x like '%text1%') as xtimes,
        (select count(*)  from table  where Column_x like '%text2%') as ytimes,
        (select count(*)  from table  where Column_x like '%text3%') as ztimes
        );