简体   繁体   中英

how to get the result of column name of a joined table having same column name?

i've joined 4 tables and 3 table have same column name called "Remarks". How can i display the result of Remarks of different tables? Here is the query

$qry = mysql_query("SELECT * FROM setup_candidate AS SC,
                                        setup_candidate_degree AS SCD,
                                        setup_candidate_work_experience AS SCWE,
                                        transaction_counselor_candidate_assignment AS TCCA
                                    WHERE SC.Candidate_No = SCD.Candidate_No 
                                    AND SCD.Candidate_No = SCWE.Candidate_No
                                    AND SCWE.Candidate_No = TCCA.Candidate_ID
                                    AND SC.Candidate_No = '$id' 
                                    ");
                    if(!$qry){ echo "problem"}

when i display the result in a page how do i address the specific Remarks Table?

for example i did

$row = mysql_fetch_array($qry);

echo $row['Remarks'];

lets say i want to get the Remarks of setup_candidate_degree table ? Can you help me ? Thanks XD

  1. Add alias for those fields.

    SELECT *, setup_candidate_degree.Remaks as setup_candidate_degree_Remaks

  2. Get by number from $row array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM