select 'QG'+id from tablename

解决方案 »

  1.   

    select 'QG'+cast(id as varchar) from tablename
      

  2.   

    错误 
    SQL 语句 :  select 'QG'+cast(id as varchar) from product LIMIT 0, 30MySQL 返回:
    You have an error in your SQL syntax near '(id as varchar) from product LIMIT 0, 30' at line 1返回
      

  3.   

    select 'QG'+convert(varchar,id) from tablename
      

  4.   

    select concat('QG',id) qid from tablename
      

  5.   

    真晕了,居然有这么多用+号的。
    把auto_increment去掉,然后
    update tbname set id=concat('QG',id)
    这个是改变表数据的,慎用
      

  6.   


    错误 
    SQL 语句 :  update product set id=concat('QG',id)MySQL 返回:
    Duplicate entry '0' for key 1
      

  7.   

    呵呵!id是int型,怎么能加上字母呢?
      

  8.   

    this,刚试过:SELECT concat('gp',cast(id as char)) FROM tablename
      

  9.   

    按要求修改一下,哈哈:SELECT concat('QG',cast(id as char)) FROM tablename