how to auto generate a Varchar in phpmyadmin database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viana2020
    New Member
    • Aug 2015
    • 14

    how to auto generate a Varchar in phpmyadmin database

    i am trying to feed a number to database in this case my reference number which is of a (AAA/BBB/28AUG2015 - 4082) format,
    which should be selected by user,and the date should be the system date while the last number should be auto-generated in that sequence.
    the 1st and 2nd values are fixed.kindly i am unable to do that on phpmyadmin DB someone help please.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    "i am unable to do that on phpmyadmin DB "

    There's no such thing as "phpmyadmin DB". You are probably meaning that you cannot create a query in your database ('MySQL') that will select a record containing a field with the value "AAA/BBB/28AUG2015 - 4082"


    Code:
    SELECT *
    FROM <tablename>
    WHERE field LIKE concat('AAA/BBB/', upper(date_format(now(),'%d%b%Y')), '%')
    This will select all records with values that start with 'AAA/BBB/29AUG2015'

    Comment

    • viana2020
      New Member
      • Aug 2015
      • 14

      #3
      thanks Luuk for the correction.but now how do i insert that in DB? please

      Comment

      • RonB
        Recognized Expert Contributor
        • Jun 2009
        • 589

        #4
        It looks to me like you have an XY problem.

        The answer to the question you're asking (which is not the question you should be asking) is to select the record then (outside of sql) parse/split that field value into 2 values (sting and int), then increment the int and use another sql statement to insert the concatenated values.

        Comment

        Working...