[b]myTable[/b]
(1) 3 6
(2) 8 4
(3) 7 2
(4) 5 1
[b]myTable1[/b]
(1) Mary
(2) Jane
(3) Tom
(4) Carol
(5) Jack
(6) Judy
(7) Rudy
(8) Chris
I have 2 tables like the above and I like to produce my target result like the below.
[b]target result[/b]
(1) Tom Judy
(2) Chris Carol
(3) Rudy Jane
(4) Jack Mary
The code below is one of steps toward the target result.
[b]on the way code[/b]
select myTable.id,name from myTable
left join myTable1 on male=myTable1.id
order by myTable.id
[b]on the way result[/b]
(1) Tom
(2) Chris
(3) Rudy
(4) Jack
The code below is one of trials but failed.
[b]trial code2[/b]
(select myTable.id,name from myTable
left join myTable1 on male=myTable1.id)
UNION
(select myTable.id,name from myTable
left join myTable1 on female=myTable1.id)
order by myTable.id
[b]trial result[/b]
mysql_fetch_array(): supplied argument is not a valid MySQL result resource.
left join myTable1 on male=myTable1.id
left join myTable1 on female=myTable1.id
I guess I have to create one more cyber table (t1) in query …
What does “aliases” here mean in English?
life is like a box of chocolates,
you eat fast your life will critically down with fat, diabetes, or something.
you eat steadily the box will be empty at last.
Say you were dealing with fixtures for a football league (soccer), there’s always a home team and an away team, the details for each are all kept in a table called “teams” so for the home team the table alias would be done by (in the FROM clause):
teams AS home_team
then in the same query (also in the FROM clause) for the away team the table alias would be done: