insert...select

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmc
    New Member
    • Nov 2006
    • 9

    insert...select

    this gives me error message: Subquery returns more than 1 row

    "INSERT INTO customerbook (booking_ID,roo m_Type)
    values((select booking_ID from bookings where booking_ID = bookings.bookin g_ID),'$a')"

    any solution?
  • cyberking
    New Member
    • Jan 2007
    • 84

    #2
    Originally posted by mmc
    this gives me error message: Subquery returns more than 1 row

    "INSERT INTO customerbook (booking_ID,roo m_Type)
    values((select booking_ID from bookings where booking_ID = bookings.bookin g_ID),'$a')"

    any solution?
    Hi!
    OMG. Your query seems like a riddle to me, I mean bookings.bookin _id where booking_id=book ing.booking_id. lol, dont you think it rhymes sort of..

    Anyways, yes. What is happening here is your subquery which is
    select booking_ID from bookings where booking_ID = bookings.bookin g_ID
    returns more than one selection. Thereby the error subquery returns more than one value. That is your query results in more than one match for your condition
    where booking_ID = bookings.bookin g_ID .

    Try ifinding out your subquery result
    $query = select booking_ID from bookings where booking_ID = bookings.bookin g_ID
    $result = mysql_query($qu ery);
    $ans = mysql_fecth_ass oc($resullt);

    Try echoin the values and you ll know whats goin wron

    Regards
    CyberKing
    www.bytesandbyt es.com

    Comment

    Working...