|
Posted by paladin.rithe@gmail.com on 03/04/07 14:02
On Mar 3, 1:07 pm, Dikkie Dik <nos...@nospam.org> wrote:
> > I have 2 statements that I'd like to string together in a query, but
> > according to everything I'm seeing, it's not possible.
> > What I'm doing is an insert of a row, where the primary key is an auto
> > increment. I want to retrieve that by using LAST_INSERT_ID(). I
> > tried sending another query after the first (once I knew that it the
> > data was what I need) but it didn't return anything. It seems that
> > that function can't be used in separate calls or something. Either
> > that or there's a setting that I need to check. Any ideas?
>
> It is already suggested that you post the queries themselves. But it
> could be something else: If you issue the queries in separate
> connections, they will not work together. A connection in MySQL (I
> assume you are using MySQL) is like a session: variables only exist
> within that session and the result of LAST_INSERT_ID is also not visible
> to other connections.
>
> So you do issue the queries in one connection, I hope?
>
> Best regards
I actually solved it a different way. I was using a unique value to
create the table as it was, so I just used that instead.
I was using "SELECT LAST_INSERT_ID();" as my second query. The first
just being a general insert. I'm positive there was nothing wrong
with my queries because I put them in the console, and it worked
fine. I think there might be some issues with my db wrapper, but
that's a separate issue I think.
Navigation:
[Reply to this message]
|