我有 3 个表,分别称为公司、客户和评论。首先我添加公司,然后将客户添加到客户表中,最后客户在评论表中添加评论。
这是公司表的结构:
id company type address
1 abc running xyz
2 def old asd
这是客户表的结构:
cid company customername location
1 1 test delhi
2 2 test1 noida
这是评论表的结构:
id company customer comments
1 1 test testcomments
2 2 test1 test1comments
现在我想按客户姓名、公司名称和位置在 cutomers 表中搜索,所以我尝试了这个,但无法获得关于搜索的评论的价值,我该如何实现它。
这是我对公司名称和位置的搜索查询:
$sql = mysql_query("Select * from customers AS cust INNER JOIN company AS comp ON cust.company = comp.id where cust.name like '%$term%' or cust.location like '%$term%' or comp.company like '%$term%'");