Page 1 of 1

whats wrong with this query..

Posted: Thu Jan 24, 2008 8:27 am
by djdon11
hello friends i have a join query for search the query is as follows : - >

Code: Select all

 
 
$sql_search="select a.*,b.*,c.* from users as a,students as b, cm_countries as c where (a.login like '%".$search."%' or a.name like '%".$search."%' or a.mail like '%".$search."%' or a.city like '%".$search."%') or (c.country like '%".$search."%'and a.country=c.country_id)  and a.id=b.student_id and user_type!=1 and b.teacher_id=$userid";
 
but when i search by the login or email or by name than it gives muyltiple records equal to the countries in my country table

please let me know whats wrong with this query ...

Re: whats wrong with this query..

Posted: Thu Jan 24, 2008 8:35 am
by aceconcepts
The exlamation mark is not used in SQL queries.
and user_type!=1
Instead use:

Code: Select all

and user_type<>1

Re: whats wrong with this query..

Posted: Thu Jan 24, 2008 10:26 am
by VladSun
I think you need JOIN ...

@aceconcepts
I suppose this is MySQL ...

[sql]mysql> SELECT 1!=1;+------+| 1!=1  |+------+|    0   |+------+1 row IN SET (0.00 sec) [/sql]