Jump to content

Problems with complex query


dbk

Recommended Posts

Hi guys

 

I'm trying to make a mysql search function in my php page.

 

The query looks like this and works fine:

 

$search_contact_sql = "SELECT * FROM contact INNER JOIN project_contact USING (contact_id) WHERE
                        (contact_title LIKE '%$search_contact%'
                        OR contact_first_names LIKE '%$search_contact%'
                        OR contact_surname LIKE '%$search_contact%'
                        OR contact_company_relation LIKE '%$search_contact%'
                        OR contact_company_section LIKE '%$search_contact%'
                        OR contact_adress LIKE '%$search_contact%'
                        OR contact_postal_number LIKE '%$search_contact%'
                        OR contact_city LIKE '%$search_contact%'
                        OR contact_phone LIKE '%$search_contact%'
                        OR contact_fax LIKE '%$search_contact%'
                        OR contact_cellphone LIKE '%$search_contact%'
                        OR contact_private_phone LIKE '%$search_contact%'
                        OR contact_mail LIKE '%$search_contact%'
                        OR contact_notes LIKE '%$search_contact%')
                        AND project_id != $project_id
                        ORDER BY contact_title";

 

But... I want to exclude the result of this query in the search result:

 

$search_contact_sql = "SELECT * FROM contact JOIN project_contact USING (contact_id) WHERE
                        project_id = $project_id
                        ORDER BY contact_title";

 

Is that somehow possible???

 

Link to comment
Share on other sites

Hi fenway

 

I can't figure out where I'm missing parents?

 

Is it to subtract one query from the other or.. is it in one of the queryes???

 

Each query gives the result I want, but I just want the 2. query result subtracted from the first query!

 

I've been searching nearly all googles result to find a solution!!  :'(

Link to comment
Share on other sites

Thanks for the reply!

 

I simply gave up on making the query I wanted!

 

Instead I made a array to contain the one query I could use with the in_array function to check wich results from the other query I would make pass!

 

Hope it made sens!! anyway.. it works!!  ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.