Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 03-08-2006, 08:40 AM formula in mysql
Heba's Avatar
Average Talker

Posts: 28
Trades: 0
hi

I was wondering if it is possible to add a formula in mysql?
like for example if i want to generate and automatic ID but this ID must contain lets say 1st 3 letters of the username and year he joined
Heba is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-08-2006, 02:52 PM Re: formula in mysql
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
If this ID is just composed from pieces of the other columns, then there is no point creating it as a new column since that information is already in the database. In this case the username and date of joining are both 'candidate keys' which together provide a (possibly) unique ID.

If you were to want to select based on this id, then you could do something along the lines of
Code:
SELECT CONCAT(SUBSTR(username,1,3),date_joined)) from users;
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-11-2006, 01:11 AM Re: formula in mysql
Heba's Avatar
Average Talker

Posts: 28
Trades: 0
ill try this ..

but will the same work in MS SQL Server?
Heba is offline
Reply With Quote
View Public Profile
 
Old 03-11-2006, 06:48 AM Re: formula in mysql
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
should do.

It's ANSII SQL rather than MySQL specific
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to formula in mysql
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67733 seconds with 12 queries