i have MYSQL database where a table have a field that contains multiple values in each cell. where these values are a foreign key of another table.
inspection_date:
where the emplyee field will have multiple values be cause more than one employee had done the inspection.
employee
can anyone help me to use select query
$query_site_location =$wpdb->get_results("select DISTINCT
l.siteID,
l.locationName,
n.inspectionDate,
s.employeeID
from site_location l
LEFT
JOIN inspection_info n
on l.siteID = n.siteID
LEFT
JOIN employee s
on n.employeeID = s.employeeID");
the result must be in the field of employee (6-7) for the first row
A THIS relation is many to many we must create a third entity in order to handle the primary keys of both tables.
employee:
employeeID(PRIMARY KEY)
employeeName
inspection_info:
inspectionID(PRIMARY KEY)
inspectionDate
employeeID
inspection_site:
inspectionID(PRIMARY KEY)
siteID(PRIMARY KEY)
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.