473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about altering table

i have a field in a table called refid which is varchar defined as NULL.

presently every time an insert query is executed i get the lastid and use this to update the refid field in such a way that this field records information like E1 E2 E3..... as per the code below.
---------------------------------------------------------------
$lastid = mysql_insert_id();
UPDATE tablename SET refid = 'E$lastid' WHERE ref = '$lastid'
---------------------------------------------------------------

now what i need is instead of the refid starting from E1 E2 E3.... is it possible to chnage this to E101 E102 E103......

please provide the sql query in order to get this format.

also since i am presently doing a test with the table i dont mind dropping the table and recreating the table in order to get the above result.

please advice.

thanks.
Jan 2 '08 #1
2 1023
amitpatel66
2,367 Expert 2GB
i have a field in a table called refid which is varchar defined as NULL.

presently every time an insert query is executed i get the lastid and use this to update the refid field in such a way that this field records information like E1 E2 E3..... as per the code below.
---------------------------------------------------------------
$lastid = mysql_insert_id();
UPDATE tablename SET refid = 'E$lastid' WHERE ref = '$lastid'
---------------------------------------------------------------

now what i need is instead of the refid starting from E1 E2 E3.... is it possible to chnage this to E101 E102 E103......

please provide the sql query in order to get this format.

also since i am presently doing a test with the table i dont mind dropping the table and recreating the table in order to get the above result.

please advice.

thanks.
Try this:

Expand|Select|Wrap|Line Numbers
  1. $lastid = mysql_insert_id();
  2. $lastid = $lastid + 100;
  3. UPDATE tablename SET refid = 'E$lastid' WHERE ref = '$lastid'
  4.  
  5.  
Jan 2 '08 #2
mwasif
802 Expert 512MB
What would you like refid to be if the $lastid are 100,250,9786. Do you want to plus 100 as amitpatel66 suggested or you want to append '10' with $lastid?
Jan 3 '08 #3

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

Similar topics

5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
7
by: chessplayer | last post by:
Greetings Folks, I am trying to understand how DB2 locks data and can't believe my eyes. Have read the literature about the difference isolation levels and have a general understanding about...
12
by: Bernie Yaeger | last post by:
My client has a visual foxpro app that he wants me to hook into. I'm connecting to it via odbc with this connectionstring: Dim oconn_d As New OdbcConnection("Driver={Microsoft Visual FoxPro...
1
by: Jim | last post by:
Hi, I want to add a field to a table in a database that is live and being accessed from the web. I'm using phpMyAdmin and when I try to add the field I get error #1142...
3
by: xllx.relient.xllx | last post by:
I have a question about an example presented in the book "INFORMIT C++ Reference Guide" by Danny Kalev: <code> string getmagicword() ( return string("Supercalifragilisticexpialidocious"); );
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
1
by: zufie | last post by:
Hi, I want to specifying a foreign key by altering a table. First, I create an ORDERS table without specifying a foreign key. Here is my code: CREATE TABLE ORDERS (Order_ID integer,...
6
by: giladp1 | last post by:
Hi, I have a table named tblPeople for storing information about people. It includes fields such as PersonID, FirstName, LastName etc.. I need to store information about measurements such as...
6
by: Jeff | last post by:
....still new to visual studio 2005 and vb.net I have a master page with a content placeholder. The content page has a table in the content placeholder (placed there via dragging from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.