whats wrong with this query..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

whats wrong with this query..

Post 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 ...
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: whats wrong with this query..

Post by aceconcepts »

The exlamation mark is not used in SQL queries.
and user_type!=1
Instead use:

Code: Select all

and user_type<>1
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: whats wrong with this query..

Post 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]
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply