Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Define separate fields with a common name in a join

Status
Not open for further replies.

bsanderson

IS-IT--Management
Mar 17, 2020
4
US
I'm joining two MySQL tables linking the JobNo field on one to the JobNumber field on the other.

SELECT * FROM drawings LEFT JOIN jobs ON drawings.JobNo = jobs.JobNumber
$result = mysqli_query($link, $query);

This works as intended but I have a field called Revision in both tables and the data in them is not the same. How do I differentiate between them?

I tried this but it didn't works

$Revision(mysqli_result($result,$i,"jobs.Revision");
$Rev(mysqli_result($result,$i,"drawings.Revision");

Any help will be greatly appreciated
 
Hi

The table names are not kept in the results, only the field names. Or field aliases, if specified :
Code:
[b]SELECT[/b] [teal]*,[/teal] jobs[teal].[/teal]Revision [b]as[/b] [i][green]"jobs.Revision"[/green][/i][teal],[/teal] drawings[teal].[/teal]Revision [b]as[/b] [i][green]"drawings.Revision"[/green][/i] [b]FROM[/b] drawings [b]LEFT JOIN[/b] jobs [b]ON[/b] drawings[teal].[/teal]JobNo [teal]=[/teal] jobs[teal].[/teal]JobNumber
( I just used the aliases you tried to extract from the result. But you can choose other, possibly more descriptive aliases. )


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top