Results 1 to 4 of 4

Thread: MYSQL Query

  1. #1
    Join Date
    Jun 2013
    Posts
    9

    Unanswered: MYSQL Query

    Hi,

    i have two table :- Products_tbl and Productdiary_tbl

    Note: Text content in the code blocks is automatically word-wrapped
    Product_tbl data :-

    product_id(PK) | name | update_date | price

    1 | prod1 | 25-07-2013 | 10
    2 | prod2 | 26-07-2013 | 11
    3 | prod3 | 27-07-2013 | 12
    4 | prod4 | 28-07-2013 | 13

    Productdiary_tbl data :-

    id (PK) | product_id | update_date | price
    101 | 1 | 25-07-2013 | 9
    102 | 2 | 24-07-2013 | 11
    103 | 1 | 29-07-2013 | 12
    104 | 3 | 25-07-2013 | 15
    105 | 1 | 30-07-2013 | 18
    106 | 2 | 31-07-2013 | 20
    107 | 3 | 1-08-2013 | 40



    i want to get price from Productdiary_tbl for latest date (so only one record i want ), if entry is not there then price will come from Product_tbl (if no record in subtable then take the record from main table) table like here product_id - 4 entry in not in Productdiary_tbl for that price will come from Product_tbl.

    i used below query for get the data but i am not getting data :-

    select products_tbl.id,products_tbl.PRICE from products_tbl
    where products_tbl.id not in
    (select productsdiary_tbl.id,productsdiary_tbl.price from productsdiary_tbl where productsdiary_tbl.datee = (select max(productsdiary_tbl.datee) from productsdiary_tbl))
    union
    select productsdiary_tbl.id,productsdiary_tbl.price from productsdiary_tbl where datee =(select max(productsdiary_tbl.datenew) from productsdiary_tbl));


    Thanks
    Anchit

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >MYSQL Query
    if really MYSQL query, then why did you post in Oracle forum instead of dedicated MYSQL forum?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking

    Quote Originally Posted by anacedent View Post
    if really MYSQL query, then why did you post in Oracle forum instead of dedicated MYSQL forum?
    Maybe because we here at the Oracle Forum are THE BEST of THE BEST?
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Jun 2013
    Posts
    9
    Quote Originally Posted by LKBrwn_DBA View Post
    Maybe because we here at the Oracle Forum are THE BEST of THE BEST?
    don't think too much ... by mistakenly i post my question here..... can someone transfer my post in MYSQL thread or do i need to copy and paste it ?

Posting Permissions

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