Jump to content

Recommended Posts

Hey guys,

 

I have 3 tables I am joining in a query. One is a table with user information, the other is a Report table, and one one is a comments table.

 

What I am doing is allowing users to report a comment or picture for abuse. So when I am on my admin page I want to see what comments have been reported and who they were reported by. I am also looking to display information about the comment etc.

 

Anyway my problem lies within my joins. I am already returning the UserName column of the person who reported the comment but I also want to return the UserName of the person who wrote the comment that reported.

 

Can I mod the following query to make this happen?

 

SELECT CRID, CID, ReportByAccID, Date, UserName, CommentBy, Comment, DateTime FROM CommentReports LEFT JOIN users ON CommentReports.ReportByAccID = users.AccID LEFT JOIN truck_image_comments ON CommentReports.CID = truck_image_comments.ComID ORDER BY CRID;

 

IE Can I do something like UserName2 = users.UserName where users.AccID = truck_image_comments.CommentBy;

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/135457-can-you-create-alias-columns-in-mysql/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.