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
https://forums.phpfreaks.com/topic/205275-problems-with-complex-query/
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!!  :'(

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.