vendredi 11 août 2017

How to do random select from two tables with the exception?

I have two tables

[users] id, username, age, sity .... and other

and

[teacherlook] id, userid, teachid, data

When teacher look user from first table [users], he insert value to the second table

NULL, userid (it is id value from first table), teacherid (it is unic id of teacher - can may be 1,2,3 ... 10), and time in unix

It's done, it works,

Problem with second part of script:

The teacher should see 10 random users whom he has not yet tested - those who are not yet in the second table.

I try

SELECT * FROM users JOIN teacherlook WHERE users.age>18 AND (users.id<>teacherlook.userid AND teacherlook.teachid<>$teacherid) limit 0,10 

And get a blank issue. Please, help make the right request to select 10 random users from the first table, with the exception of the users viewed by the teacher in the second table.




Aucun commentaire:

Enregistrer un commentaire