#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Mysql replace fields from another table


    I have two tables:

    id lk_make model lk_gear_box_type lk_fuel_type price_without_vat year mileage
    1 5 A3 80 76 4000 2003 124000
    2 5 80 79 78 800 1991 194000
    3 5 A4 79 76 5000 2003 112000
    4 13 Voyager 79 78 1500 1997 106300
    5 51 Zafira 79 76 3800 2004 98000
    6 75 V70 79 76 4000 2001 172000
    7 61 9-5 79 76 4100 2004 101000


    and

    Table: globals

    id description lk_codetable
    2 Alfa Romeo 1
    3 Alpina 1
    4 Aston Martin 1
    5 Audi 1
    6 Austin Morris 1
    7 Austin Rover 1
    8 Bentley 1
    9 BMW 1
    10 Buick 1
    11 Cadillac 1
    12 Chevrolet 1
    13 Chrysler 1
    14 Citroen 1
    15 Cobra 1
    16 Daewoo 1
    17 Daihatsu 1
    18 De Tomaso 1
    19 Dodge 1
    20 Eagle 1
    21 Ferrari 1
    22 Fiat 1
    23 Ford 1
    24 GAZ 1
    25 GMC 1
    26 Honda 1
    27 Hyundai 1
    28 Innocenti 1
    29 Isuzu 1
    30 Iveco 1
    31 Jaguar 1
    32 Jeep 1
    33 Kia 1
    34 Lada 1
    35 Lamborghini 1
    36 Lancia 1
    37 Land Rover 1
    38 Lexus 1
    39 Lincoln 1
    40 Lotus 1
    41 Mahindra 1
    42 Maserati 1
    43 Mazda 1
    44 Mercedes-Benz 1
    45 MG 1
    46 Mini 1
    47 Mitsubishi 1
    48 Morgan 1
    49 Nissan 1
    50 Oldsmobile 1
    51 Opel 1
    52 Peugeot 1
    53 Plymouth 1
    54 Pontiac 1
    55 Porsche 1
    56 Proton 1
    57 Range ROVER 1
    58 Renault 1
    59 Rolls-Royce 1
    60 Rover 1
    61 Saab 1
    62 Seat 1
    63 Skoda 1
    64 Smart 1
    65 SsangYong 1
    66 Subaru 1
    67 Suzuki 1
    68 Talbot 1
    69 Toyota 1
    70 Trabant 1
    71 Triumph 1
    72 Vauxhall 1
    73 VAZ 1
    74 Volkswagen 1
    75 Volvo 1
    76 Diesel 2
    77 Gas 2
    78 Petrol 2
    79 Manual 3
    80 Automatic 3
    81 Steptronic 3


    I would like to replace lK_make from first table with appropriate field from second table column description.
    Fore example in first row instead of 5 for lK_make it would show Audi, because audi is with 5 as id

    thank you.
    Br
    Edgars
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    And what have you tried.
  4. #3
  5. Hockey face
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    St. Catharines, Canada
    Posts
    8,147
    Rep Power
    1317
    you wouldn't do a permanent replacement, you would use a JOIN on the tables and show the appropriate columns.

IMN logo majestic logo threadwatch logo seochat tools logo