Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Unanswered: 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??

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •