-2

我正在尝试在数据库中搜索用户输入的术语。这是我正在使用的 MYSQL 语句:

SELECT CompanyName, FirstName, LastName, Phone, Email, City, Rep, id 
FROM calls 
WHERE Rep='JSC' && CompanyName || FirstName || LastName || PhoneMisc1 || Email || City LIKE '%$terms%'

问题是,它不仅返回 Rep='JSC' 的记录,而且它的其余部分都用于返回类似于术语的列。

4

1 回答 1

0

做喜欢

SELECT CompanyName, FirstName, LastName, Phone, Email, City, Rep, id  
FROM calls WHERE Rep='JSC' and 
(
CompanyName LIKE '%$terms%' 
or
FirstName LIKE '%$terms%' 
 or 
 LastName LIKE '%$terms%' 
or 
PhoneMisc1 LIKE '%$terms%' 
or 
Email LIKE '%$terms%' 
or 
City LIKE '%$terms%'
) 
于 2012-06-01T14:03:23.773 回答