By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

how to auto generate a Varchar in phpmyadmin database

P: 14
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.
Aug 28 '15 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,035
"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"


Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM <tablename>
  3. WHERE field LIKE concat('AAA/BBB/', upper(date_format(now(),'%d%b%Y')), '%')
  4.  
This will select all records with values that start with 'AAA/BBB/29AUG2015'
Aug 29 '15 #2

P: 14
thanks Luuk for the correction.but now how do i insert that in DB? please
Aug 31 '15 #3

Expert Mod 100+
P: 589
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.
Aug 31 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.