mysql - Adding extra field to sql query -


I have written a query for a private messaging system but I would like to add a novel field to the query but to make sure Not to do this how to do it.

At the moment it receives the sender's username, but not the receiver, but it receives both the sender / receiver ID.

How do I name the user name to add an additional field to my query? I have thought about a nested selection.

This is my current query

  SELECT p *, U. Username, in the form of sender, as a DATE_FORMAT (u.signup_date, '% b% Y') from Jyotet, M.Veter from PrivateMaseGrak P Inner User User Usage on U PseenderID = U.Arderid Inner Jean Amus M On M Usurid = U. USRead WHERE p.messageid = '1' LIMIT 1  

And there are table structures

  If not present on table, make (Default) 'default' ',' avatar 'varchar (100), not default' ',' default '', 'avatar' ('f'), 'default' 'Signature' is not a text, 'Alert' NAM ('Y', 'N') by default 'Y', primary key (`math '))' Private '(' Message 'INT (10) Faucet Auto_Inrme , 'Sender id' int (4) no default '0' ',' recipient 'INT (4) tap default' 0 ',' subject 'varchar (255) tap default' ', `message` text no, zero, dated Date not zero default '0000-00-00', primary key (`messageid`) if no user exists (` userid` int (25) do not auto_increment, `first_name` varchar (25) not default default '' , 'Email' varchar (255) tap default '', username 'varchar (25) tap default' ',' password 'verbatim (32) tap default' ',' salt 'four (3) Default '', 'gender' varchar (6) no zero default '', 'user_level' enum ('0', '1', '2', '3') by default '0', 'signup_date` Datetime tap default is '0000-00-00 00:00: 00', 'Last_ login', 'default 0000-00-00 00:00:00', 'active' enum ('0', '1') Default not Default '0', Primary key (`User ID '))  

  SELECT p. *, Us.username as the sender, usernames as ur recipients, DATE_FORMAT (u.signup_date, '% b% Y') as joindate, from m.avatar to privateGregPINNER join us on the user p.senderid = Us.userid Join INNER user ur p.recipientid = ur.userid Inner mess missis am on M. Uread = U. Usheri D WHERE p.messageid = '1' LIMIT 1  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -