0

この状況では、ある列に steve という名前を含み、別の列に email@email.com という名前を含むすべてのレコードを検索したいと考えています。オペレーターがいないことは知っていますが、どのオペレーターかわかりません

            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))
4

2 に答える 2

0

すべてのフィールドを実際に調べている場合を除き (つまり、John Stevenson は「Steve」に一致すると見なされます)、これははるかに簡単に行うことができます...

select *
from contacts

where firstname like '%Steve%'
 and (primary_emailaddress like '%email@email.com%' or alternate_emailaddress like '%email@email.com%')
于 2013-07-31T21:32:19.103 に答える
0

Match比較より速いですlikewhere節で2回できると思います:

        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;
于 2013-07-31T22:28:55.637 に答える