简体   繁体   中英

select all field from one table and one from another table in mysql

i need to select all field from one table without specifying them, and only one field from another table in joining query, but am getting errors.

here is my code.

SELECT  staff_research.*, research_details.type
     FROM  staff_research,research_details
         INNER JOIN research_details  staff_research
               ON research_details.id = staff_research.rid

the error am getting

Unknown column 'staff_research.rid' in 'on clause'

i don't know what i am missing, any help please!

Remove research_details table from the From clause,

SELECT  staff_research.*, research_details.type
FROM  staff_research
INNER JOIN research_details 
ON research_details.id = staff_research.rid

Reference : JOIN SYNTAX

Try this:

SELECT sr.*, rd.type
FROM staff_research sr 
INNER JOIN research_details rd ON rd.id = sr.rid;

Use this:

Your syntax of INNER JOIN is not correct. Please improve it using following syntax.

SELECT  staff_research.*, research_details.type
FROM  staff_research
INNER JOIN research_details ON research_details.id = staff_research.rid

你使用: INNER JOIN research_details staff_research <-> research_details as staff_research -> error

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