Professional Web Applications Themes

is there a way to 'insert and fetch value'? - MySQL

I am writing a DB like this: --------------------------------------------------------------------- | id (auto_incremented filed) | foo | bar | --------------------------------------------------------------------- $sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1', '$string_2')"; mysql_query($sql_query, $db_handle); //how can I get id for the above inserted entry? is that possible I get it with a single mysql instruction? since each time I write a record into mysql, 'id' is incremented, how can I get the id that an insertion corresponds to (can I get it with a single mysql instruction)? Thanks,...

  1. #1

    Default is there a way to 'insert and fetch value'?

    I am writing a DB like this:
    ---------------------------------------------------------------------
    | id (auto_incremented filed) | foo | bar |
    ---------------------------------------------------------------------

    $sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
    '$string_2')";
    mysql_query($sql_query, $db_handle);
    //how can I get id for the above inserted entry? is that possible I
    get it with a single mysql instruction?


    since each time I write a record into mysql, 'id' is incremented,
    how can I get the id that an insertion corresponds to (can I get it
    with a single mysql instruction)?

    Thanks,

    newbie Guest

  2. #2

    Default is there a way to 'insert and fetch value'?

    I am writing a DB like this:
    ---------------------------------------------------------------------
    | id (auto_incremented filed) | foo | bar |
    ---------------------------------------------------------------------

    $sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
    '$string_2')";
    mysql_query($sql_query, $db_handle);
    //how can I get id for the above inserted entry? is that possible I
    get it with a single mysql instruction?


    since each time I write a record into mysql, 'id' is incremented,
    how can I get the id that an insertion corresponds to (can I get it
    with a single mysql instruction)?

    Thanks,

    newbie Guest

  3. #3

    Default is there a way to 'insert and fetch value'?

    I am writing a DB like this:
    ---------------------------------------------------------------------
    | id (auto_incremented filed) | foo | bar |
    ---------------------------------------------------------------------

    $sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
    '$string_2')";
    mysql_query($sql_query, $db_handle);
    //how can I get id for the above inserted entry? is that possible I
    get it with a single mysql instruction?


    since each time I write a record into mysql, 'id' is incremented,
    how can I get the id that an insertion corresponds to (can I get it
    with a single mysql instruction)?

    Thanks,

    newbie Guest

  4. #4

    Default Re: is there a way to 'insert and fetch value'?

    On Fri, 20 Jul 2007 09:31:58 +0200, newbie <com> wrote:
     

    Please do not multi- and/or crosspost.
    Answered in comp.lang.php
    --
    Rik Wasmus
    Rik Guest

  5. #5

    Default Re: is there a way to 'insert and fetch value'?

    Rik wrote: 
    >
    > Please do not multi- and/or crosspost.
    > Answered in comp.lang.php
    > --Rik Wasmus[/ref]

    Actually, cross-posting is good. Multi-posting is not.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  6. #6

    Default Re: is there a way to 'insert and fetch value'?

    On Fri, 20 Jul 2007 13:04:52 +0200, Jerry Stuckle
    <net> wrote:
     
    >> Please do not multi- and/or crosspost.
    >> Answered in comp.lang.php
    >> --Rik Wasmus[/ref]
    >
    > Actually, cross-posting is good. Multi-posting is not.
    >[/ref]

    Crossposting is the lesser of two evils. Not good except for a few rare
    exceptions.
    --
    Rik Wasmus
    Rik Guest

  7. #7

    Default Re: is there a way to 'insert and fetch value'?

    Message-ID: <com> from Jerry
    Stuckle contained the following:
     

    s/is/can be

    --
    Regards,

    Geoff Berrow
    Geoff Guest

  8. #8

    Default Re: is there a way to 'insert and fetch value'?

    On Jul 20, 4:04 am, Jerry Stuckle <net> wrote: 
    > [/ref]
    > [/ref]
    > [/ref]

    >
    > Actually, cross-posting is good. Multi-posting is not.[/ref]
    Sorry, I did multi-posting (accidentally) because the first post was
    not shown for more than 10 minutes (during which time periods I posted
    the 2nd). Sorry about that, and by the way, can anyone explain a bit
    why this happened?

    Thanks
     


    newbie Guest

  9. #9

    Default Re: is there a way to 'insert and fetch value'?

    > can anyone explain a bit 

    Yes: You use Google Groups. Google Groups is bad. Try a nntp server and a
    news client.
    --
    Rik Wasmus
    Rik Guest

Similar Threads

  1. Question Insert from ASP to SQL using recordset data as values in insert statement
    By JasonM in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 13th, 05:54 PM
  2. What's faster - loop for insert or insert...select.
    By mr. modus in forum Coldfusion Database Access
    Replies: 2
    Last Post: December 10th, 01:57 AM
  3. portinstall: fetch(1) doesn't fetch
    By h in forum FreeBSD
    Replies: 4
    Last Post: March 11th, 05:10 PM
  4. Bug in Fetch?
    By Dennis in forum Mac Networking
    Replies: 3
    Last Post: June 4th, 01:33 AM
  5. Replies: 3
    Last Post: September 30th, 09:24 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139