SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2012
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    loading values from a column of one table to the column of another

    Hi there,
    I have three tables products(id,abc,xyz,etc...)
    product_descriptions(product_id,id,description,summary,etc)
    prices(id,ref,price,warranty,product_id)

    I have 2 already create and populated tables and one new table prices

    i need to load the values of prices.ref from the product_descriptions.description
    such that the value of prices.ref is a substring that can be obtained using the result of query
    SELECT SUBSTRING( description, INSTR( description, 'Ref' ) +4 ) , description
    FROM product_descriptions
    WHERE description LIKE '%Ref%'
    LIMIT 0 , 30

    and I also need to load the corresponding product_id for the description from which the prices.ref is derived as the product_id of price...

    Can anyone help me with this issue...

    currently prices table has no values , i need to populate both ref and their corresponding product_ids

    prices.ref is an integer and product_descriptions.description is mediumtext

    PS: I know the tables are not normalized , but I am still required to do it this way...
    Thanks.

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Have a read about the IEINSERT SELECT syntax
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2012
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi , do we have a update select statement as well? ...i can't find it though :S

    and Thanks for the help !!!

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Fati Kom View Post
    Hi , do we have a update select statement as well? ...i can't find it though :S
    not exactly

    you can update one table from anouther, though

    look in da manual under UPDATE syntax for joined update
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2012
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much!!! you people are very helpful!


Bookmarks

Posting Permissions

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