Total members 9952 | Gratitudes |It is currently Sat Feb 11, 2012 1:49 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 4 posts ] 
Author Question
 Question subject: Create auto numbered column in mysql query
PostPosted: Mon Apr 26, 2010 7:38 am 
Offline
Newbie
User avatar

Joined: Mon Apr 26, 2010 7:31 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

Create auto numbered column in mysql query

select @rownum:=@rownum+1 nowef,
p.* from item p, (SELECT @rownum:=0) r
order by item_code
desc limit 10;
:wink: :wink:


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create auto numbered column in mysql query
PostPosted: Mon Apr 26, 2010 9:33 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 57 time
thanks for sharing , I never tried such query before .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create auto numbered column in mysql query
PostPosted: Sun May 02, 2010 10:19 am 
Offline
Newbie
User avatar

Joined: Sun May 02, 2010 10:07 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
:wink: :i_love: :blush: :beee: :sohappy: :rolf: :anno:



sameeraa4ever wrote:
Create auto numbered column in mysql query

select @rownum:=@rownum+1 nowef,
p.* from item p, (SELECT @rownum:=0) r
order by item_code
desc limit 10;
:wink: :wink:


Thanks for sharing of that that's very helpful!

make money from home


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Create auto numbered column in mysql query
PostPosted: Tue May 04, 2010 5:50 am 
Offline
Newbie
User avatar

Joined: Tue May 04, 2010 5:44 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
Syntax for SQL Server

The following SQL statement defines the "P_Id" column to be an auto-increment primary key field in the "Persons" table:
CREATE TABLE Persons
(
P_Id int PRIMARY KEY IDENTITY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)

The MS SQL Server uses the IDENTITY keyword to perform an auto-increment feature.

By default, the starting value for IDENTITY is 1, and it will increment by 1 for each new record.

To specify that the "P_Id" column should start at value 10 and increment by 5, change the identity to IDENTITY(10,5).

To insert a new record into the "Persons" table, we will not have to specify a value for the "P_Id" column (a unique value will be added automatically):
INSERT INTO Persons (FirstName,LastName)
VALUES ('Lars','Monsen')

The SQL statement above would insert a new record into the "Persons" table. The "P_Id" column would be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column would be set to "Monsen".


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 4 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 delete duplicate rows in mysql using php  PHP Tutorials  msi_333  2
 update query example  PHP examples  msi_333  0
 select query example in php  PHP examples  msi_333  0
 insert query example  PHP examples  msi_333  0
 how do i create the classes XX and YY?  Java  Anonymous  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team