1052: Column 'id' in field list is ambiguous

前端 未结 8 1962
面向向阳花
面向向阳花 2020-11-22 13:17

I have 2 tables. tbl_names and tbl_section which has both the id field in them. How do I go about selecting the id field,

8条回答
  •  余生分开走
    2020-11-22 13:51

    In your SELECT statement you need to preface your id with the table you want to choose it from.

    SELECT tbl_names.id, name, section 
    FROM tbl_names
    INNER JOIN tbl_section 
       ON tbl_names.id = tbl_section.id
    

    OR

    SELECT tbl_section.id, name, section 
    FROM tbl_names
    INNER JOIN tbl_section 
       ON tbl_names.id = tbl_section.id
    

提交回复
热议问题