If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > HELP!! Concatenating List

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-21-04, 11:59
lyricalistic lyricalistic is offline
Registered User
 
Join Date: Oct 2004
Posts: 1
HELP!! Concatenating List

I want to create a database with a table called "FILMS" in this table i want the "GENRE" to be calculated. Ie if I type in the letter "A" when creating a new record it should be replaced by the word "ACTION", others include:

V for ADVENTURE
N for ANIMATION
C for COMEDY
F for FAMILY etc............

I want to implement this into the CREATE TABLE statement. can someone please help me out?? I've heard of something called a lookup table and concatenating but i dont know how to use them??
Reply With Quote
  #2 (permalink)  
Old 10-21-04, 14:16
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
You won't be able to do this exactly as you think. You can't type something and have it create something else.

What you can do is give yourself a shortcut by only typing the short versions by creating two tables and then outputting from the two tables if you want your users to see them in long version.


something like:

Code:
create table mylookuptable(
shortversion char(1),
longversion varchar(15));

create table movies(
id int,
movietitle varchar(50),
movietype char(1),
foo char(10),
bar char(10));
in the mylookuptable insert data once for each type of movie genre.

in the movies table itself you would then only need the short version.

then when you want the output you can do something like:

Code:
select movietitle, longversion, foo, bar
from movies, mylookuptable
where movietype=shortversion
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On