[SOLVED] Implementation of PM

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

[SOLVED] Implementation of PM

Post by bagi »

Hi everyone, i have db
dialogs
id; INT
title; TEXT
lastMessage; INT

dialogUsers
id; INT
dialogId; INT
user; INT
haveNewMsg; BOOL

messages
id; INT
time; INT
msgText; TEXT
dialogId; INT
user; INT
isNewMsg; BOOL
How I can get dialogId, which contains some users?
Last edited by bagi on Sat Jan 04, 2014 4:35 pm, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Implementation of PM

Post by requinix »

You query for it.

Want to try explaining in more detail?
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Implementation of PM

Post by bagi »

Yes, but I wanted to ask specific query
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Implementation of PM

Post by requinix »

Then ask.
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Implementation of PM

Post by bagi »

I fixed that.
But here is new problem
mysql> insert into dialogs(title) OUTPUT INSERTED.ID values('1');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'OUTPU
T INSERTED.ID values('1')' at line 1
mysql>
What's wrong?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Implementation of PM

Post by Celauran »

There's a syntax error in your query. What is the query? What are you trying to do?
bagi
Forum Newbie
Posts: 24
Joined: Thu Oct 31, 2013 10:50 am

Re: Implementation of PM

Post by bagi »

Celauran wrote:There's a syntax error in your query. What is the query? What are you trying to do?
insert into dialogs(title) OUTPUT INSERTED.ID values('1');
I have id columns (int primary key auto_increment). After inserting values I wanna get this id

Upd: found last_insert_id()
Post Reply