Reputation: 13315
I am having a text-box which is auto complete.
When i enter the name on the text-box the auto complete will work and provide the list from table.
And when i click the save button the names which are entered in the text-box will inserted in a table. Until this, the process i working fine.
My case is : Already existing users should not show in auto-complete.
Table Structure :
Users Table
uid, name
work table
wid, from_uid, to_uid,
How the mysql query should be.. Any help regarding this will be thankful and gratedful...
Upvotes: 0
Views: 44
Reputation: 254886
select name
from users
where name like 'Jo%'
and uid not in (select to_uid
from work
where from_uid = 666)
Supposing that user entered Jo
substring and current user's id is 666
or another query that does the same (not sure which one will be more efficient in your particular case) but uses LEFT JOIN
instead of subquery:
select name
from users u
left join work w on w.from_uid = 666
and u.uid = w.to_uid
where name like 'Jo%'
and w.to_uid is null
Upvotes: 1