search

Home  >  Q&A  >  body text

mysql queries data with valid ID number field value

Some values ​​in the ID number field in the table are invalid. How can I check the valid information for the ID number? Thanks

仅有的幸福仅有的幸福2748 days ago1139

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-18 10:50:22

    Regular expression:

    ID card regex: d{6}(18|19|20)d{2}(0[1-9]|1[120])(0[1-9]|[12]d|3[01])d{3}(d|X)
    Mysql regex:

    select * 
    from table 
    where identity regexp '[[:digit:]]{6}(18|19|20)[[:digit:]]{2}(0[1-9]|1[120])(0[1-9]|[12][[:digit:]]|3[01])[[:digit:]]{3}([[:digit:]]|X)'

    reply
    0
  • 高洛峰

    高洛峰2017-05-18 10:50:22

    select * from 表 where list regexp '^[0-9]{18}$'

    reply
    0
  • Cancelreply