在这种情况下,我想在一列中找到包含名称steve的所有记录,在另一列中找到包含名称steve的所有记录。我知道我错过了一个操作员,但我不知道哪个
SELECT firstname,lastname,middlename,company_name,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_line2,personal_address_city,facebook_username,
twitter_username,googleplus_username,linkedin_username,
personal_website_url,birthday_month,notes,personal_address_zipcode,
company_address_zipcode,home_phonenumber,company_phonenumber,
cell_phonenumber,birthday_day,birthday_year,hash,image_file
FROM contacts
WHERE (
MATCH(
firstname,lastname,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_city,company_name,
company_address_line1,company_address_city,
facebook_username,twitter_username,googleplus_username,linkedin_username,
personal_website_url
)
AGAINST ('Steve email@email.com' IN BOOLEAN MODE))
答案 0 :(得分:0)
除非你真的看过每一个领域,(即约翰史蒂文森被认为是'史蒂夫'的比赛),你可以做得更简单......
select *
from contacts
where firstname like '%Steve%'
and (primary_emailaddress like '%email@email.com%' or alternate_emailaddress like '%email@email.com%')
答案 1 :(得分:0)
Match
比like
比较快。我认为你可以在where
条款中执行两次:
SELECT firstname,lastname,middlename,company_name,
primary_emailaddress,alternate_emailaddress,personal_address_line1,
personal_address_line2,personal_address_city,facebook_username,
twitter_username,googleplus_username,linkedin_username,
personal_website_url,birthday_month,notes,personal_address_zipcode,
company_address_zipcode,home_phonenumber,company_phonenumber,
cell_phonenumber,birthday_day,birthday_year,hash,image_file
FROM contacts
WHERE MATCH (firstname) AGAINST ('Steve' IN BOOLEAN MODE) > 0 and
MATCH (primary_emailaddress, alternate_emailaddress)
AGAINST ('email@email.com' IN BOOLEAN MODE) > 0;