数据表有两列第一列  第二列
  a_1   a
  b_1   b
  b_2   b
  b_3   b
  c_1   c
  c_2   c
  d_1   d用sql查询后得到结果为  a_1   a
  b_1   b
  c_1   c
  d_1   d想请问下这条sql如何去写,在线等,谢谢

解决方案 »

  1.   

    select *
    from tb
    where col1 like '%\_1'
      

  2.   

    select *
    from 数据表
    where RIGHT(第一列,2) = '_1'
      

  3.   

    感谢上面的回答,一楼我只是举了一个例子,实际上并没事每条数据都是_1结尾的,可能会是这样的
    第一列  第二列
      dsf      a
      ere      b
      22s      b
      cvc      b
      233      c
      klk      c
      111      d用sql查询后得到结果为
     
      dsf      a
      ere      b
      233      c
      111      d是不是这样就表述的更清楚一些了,请问这样的怎么去查
      

  4.   

       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
      

  5.   

    select *
    from tb
    group by col2
      

  6.   

    select * from 表名 group by 第二列名;
    看看是不是这种效果
      

  7.   

    mysql> select min(col1),col2 from tb group by col2;
    +-----------+------+
    | min(col1) | col2 |
    +-----------+------+
    | a_1       | a    |
    | b_1       | b    |
    | c_1       | c    |
    | d_1       | d    |
    +-----------+------+
    4 rows in set (0.05 sec)