I have two tables, "CategoriesTable" and "CompanyTable" I need to show all the entries from the categories table and only the entry (in the category_b in the company table.
$result = mysqli_query($conn,"SELECT * FROM categories INNER JOIN company ON categories.category = company.category_b WHERE id_com=". $id );
CategoriesTable CompanyTable
category category_b
---------------- ----------------
Vendor Client
Employee
Client
Prospect
This is within a drop down menu where the current category stored in the CompanyTable.category_b should show first. If the user wants to change the category the drop down will display the available categories in the category table.
This query only shows the matching entries between each table, so it only displays "Client".
尝试
SELECT * FROM categories LEFT JOIN company ON categories.category = company.category_b WHERE id_com=". $id
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.